Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Statistics Write a program named statistics dva that repeatedly asks a user to enter a price of an item or-1 when finished. When the user

image text in transcribed
Statistics Write a program named statistics dva that repeatedly asks a user to enter a price of an item or-1 when finished. When the user enters -1, your program will compute and display the total number of items, the average price and the standard deviation of the prices. Here is the formula for standard deviation: 17(13--1) If the user enters -1 right away, print a message that you cannot calculate any statistics. If the user enters only one number, calculate the average, but give a message that you cannot calculate a standard deviation Here is some sample output from running the program several times Enter first price, or 1 to quit: 515.20 Enter next price, or 1 to quit: 316.45 Enter next price, or -1 to quit $17.00 Enter next pelce, or -1 to quit: $15.85 Enter next price, or 1 to quit: 3.1 Number of items: 4 Average price is $16.13 Standard deviation of prices is $0.78 Enter first price, or 1 to quit: $34 Enter next price, or -1 to quit: 5-1 Number of items: 1 Average price is $34:00 Cannot calculate standard deviation for one Item Enter first price, or 1 to quit: 3-1 Number of items: No data entered. Cannot calculate statistics When you print the average and standard deviation, they must be preceded by a dollar sign and have exactly two digits to the right of the decimal point. Here is how the sum of prices and sum of squared prices fit into the standard deviation formula, Hint: Your program needs variables to keep track of the number of items entered the sum of the items, and the sum of squares. Every time you get a price (other than-1). your program will have to add one to the total number of items, add the price to the sum, and add price to the sum of squares. Your program should not calculate the average or standard

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

Students also viewed these Databases questions

Question

Explain the two meanings that the term equality can have.

Answered: 1 week ago

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago