Posted by cl on Wednesday, September 2, 2009 at 1:19am.
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:")
NUM = CONSOLE.READLINE()
for x = 1 to NUM
console.write("please type a value:")
value = Console.Readline()
total = total + value
next
console.write("The average is")
average = total / NUM
console.write(average)
Related Questions
Programming in c++ - Write a program in c++ that inputs a number [1-12] from the...
Programming - Write a pseudocode program that asks the user for an integer ...
programming logic - The program will accept user input to store the student'...
computer science - in one the chapter 3 programming challenges you were asked to...
programming logic and design - The Daily Gazette accepts classified ads in ...
devry - A small startup software developer company needs to create a program ...
computer programming - : Create a program like KBC game show where program ask ...
C Programming - Write a program that prompts the user to enter a temperature, ...
Program Logic Design - create a flowchart that shows the logic for a program ...
computer science /use java language - write the program that inputs a string ...
For Further Reading