computer science

In this exercise you will create a program that computes the average of a collection
of values entered by the user. The user will enter 0 as a sentinel value to indicate
that no further values will be provided. Your program should display an appropriate
error message if the first value entered by the user is 0.

  1. 👍
  2. 👎
  3. 👁
  1. sum=0
    loop {
    print " enter value"
    read value
    if value=0 then exit loop
    sum += value
    count += 1
    if count=0 then print "no values entered"
    else {
    avg = sum/count
    print "the average of ", count, " values is ", avg

    1. 👍
    2. 👎

Respond to this Question

First Name

Your Response

Similar Questions

  1. English

    1. I am into sports. (What is the meaning of this sentence?) 2. Exercise is good for the health. 2-1. Exercise is good for health. 2-2. Exercise is good for your health. 2-3. Exercise does good for people. (Are all correct?) 3.

  2. Health--Check my answers

    1. The best way to describe fitness is: being slim and low in body fat being big, strong, and “buffed” being flexible and having a sense of overall well-being *** all of the above 2. The best way to describe wellness is:

  3. 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

  4. computer

    Write an algorithm for a program that accepts a set of numbers and finds the smallest among them and computes the sum of the numbers accepted. The program stops when the user enters number 999. Convert the algorithm into flowchart

  1. stats

    Researchers are investigating whether people who exercise with a training partner have a greater increase, on average, in targeted exercise intensity compared with people who exercise alone. Two methods of collecting data have

  2. programming

    Example Develop a pseudocode algorithm for a program that accepts each of the average marks of 10 students in a class and computes the sum and the average mark of the class. The program should display the average mark of the

  3. Business

    Which of the following ratios would be the best way to determine how customers are paying for their purchases? a) Total asset turnover b) Inventory turnover c) Average collection period d) Current ratio I believe it would be the

  4. c programming

    write a program and create a flowchart or psuedocode that will ask the user for 3 grades. the program will calculate the average on those 3 grades. the program will display the 3 grades the average and the letter grade.

  1. programming

    create the logic for a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. create a separate method to do the calculation and return the result

  2. computer science

    Class scores: Write a program that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of

  3. statistics

    the average number of years a person takes to complete a graduate degree program is 3. the standard deviation is 4 months. Assume the variable is normally distributed. If an individual enrolls in the program, find the probability

  4. Health (Ms. Sue)

    1. Explain how the FITT formula can act as a guide when you are developing a fitness program. A: The FITT formula can act as a guide when you are developing a fitness program as it provides you with an idea of how the structure of

You can view more similar questions or ask a new question.