# programming

posted by .

I am supposed to modify this program so it begins by asking the user for the number of values. The program then uses a loop to read the specified number of values and then display their average. program is below that i worked on in class. I been working on this all day and done tired everything anybody can tell me what im missing or what i left out not sure what to do next?

dim value as integer
dim average as integer
dim total as integer
for x as integer = 1 to 5
total = total + value
next
console.write("The average is")
average = total / 5
console.write(average)

• programming -

The program has certain issues:
1. there should be a variable outside of the for loop to register the number of values, which is NOT fixed at 5.
Let's say this is stored as "num".
2. value, total and average should be decimal numbers (and not integers), because the average of 2 and 3 is 2.5.
3. The temporary variable x should preferably be declared like other variables.
4. The rest of it seems OK. Make the appropriate modifications, compile, and run as required.

DIM NUM AS INTEGER
DIM X AS INTEGER
dim value as DECIMAL
dim average as DECIMAL
dim total as DECIMAL
CONSOLE.WRITE("How many values:")
for x = 1 to NUM
total = total + value
next
console.write("The average is")
average = total / NUM
console.write(average)

## Similar Questions

1. ### computer science

in one the chapter 3 programming challenges you were asked to write a program that converts a celsius temperature to fahrenheit. Modify that program so it uses a loop to display a table of celsius from 0 to 20 and their Fahrenheit …
2. ### devry

A small startup software developer company needs to create a program that will calculate the pay of its employees. For the third version of the program, the company wants the program to accept an employee’s name, the number of hours …
3. ### Programming

Write a pseudocode program that asks the user for an integer between 1 and 12. The program is to calculate the times table for that number. So for example, if the user enters a 2, then the program has to calculate 2x1 and display the …
4. ### Programming

Write a program that would calculate and display the results for the multiplication table for values ranging from 1 to 100. Your program should print the output for each step and output a new line after 10 items. Provide your program …
5. ### programming logic and design

The Daily Gazette accepts classified ads in several categories. For most ads, the newspaper charges 10 cents per word for the first 50 words, and 8 cents per word for every word after that. Design a flowchart for a program that accepts …
6. ### intro to computer programming

Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount. Your program should use a loop …
7. ### computer programing

okay I need a little help here on next program this what it say for first one which I have done. Create a counting program that counts backward from 100 to 1 in increments of 10. #include < stdio.h > int main () { Int i; while …
8. ### java programming

1. Time Calculator Write a program that asks the user to enter a number of seconds. • There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number …
9. ### C++

// Program: name of program // Author: your name // Date Written: date you began writing the program /* Abstract: Brief description of the program */ Include in-line comments in the body of your program. You can convert temperature …
10. ### computer programming

Design the logic for a program that allows a user to enter any amount of numbers up to 10 or until a sentinal value of -1 is entered. Then the program displays the count of the numbers entered and numeric average of the numbers (not …

More Similar Questions