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 including the -1 of course).

After display the average of all the entered numbers, the
program will then display each number and its difference from that average.

  1. 👍
  2. 👎
  3. 👁
  1. x=0
    i=0
    sum=0
    while x ≠ -1
    read x
    if x ≠ -1 { v[++i] = x; sum+=x }
    end while

    print i
    if i==0 exit

    avg = sum/i
    print avg
    for j=1..i print v[j],v[j]-i

    you can add any labels you see fit for user interaction.

    1. 👍
    2. 👎
  2. lh

    1. 👍
    2. 👎

Respond to this Question

First Name

Your Response

Similar Questions

  1. Pseudocode

    Write an algorithm and pseudocode that represents a program that allows a user to enter two numbers. Your program should calculate the sum, difference (both directions), product, and quotient (both directions) of the two numbers.

  2. Programming

    Write a pseudocode to represent the logic of a program that allows a user to enter an hourly pay rate and hours worked. The program outputs the user's gross pay

  3. computer science

    Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter a value. The program multiplies the value by 10 and outputs the result…

  4. Programming

    Draw a flowchart or write pseudo code to represent the logic of a program that allows the user to enter values for the current year and the user’s birth year. The program outputs the age of the user this year. Preferably a

  1. Cmin

    Draw a flowchart and write pseudocode to represent the logic of a program that allows the user to enter two values. The program outputs the sum of and the difference between the two values.

  2. Programming

    Write pseudocode to represent the logic of a program that allows the user to enter a value for hours worked in a day. The program calculates the hours worked in a five day week and the hours worked in a 252 day work year. The

  3. CIS

    Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter a value. The program multiplies the value by 10 and outputs the result.

  4. Programming

    Language - PYTHON Design a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15% tip and 7% sales

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

  2. Programming logic and design

    Draw a flow chart to represent the logic of a program that allows the user to enter five values. The program prints the modulus(%) of the five values

  3. Computer Science

    Design a program that will ask the user to enter the amount of a purchase. The program should the compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program

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

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