Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm using C++ compiler Your first task is to compute the average of some user input. Your program should continually prompt a user to input

image text in transcribed

I'm using C++ compiler

Your first task is to compute the average of some user input. Your program should continually prompt a user to input positive integer values that will be included in the average. When the user inputs a value of-1, your program should compute the average of all of the values previously input by the user and print it out to the screen. The average value should be printed to the screen with two decimal places of precision. Example run (user input in bold) Enter a value to include in the average: 8 Enter a value to include in the average: 3 Enter a value to include in the average: 5 Enter a value to include in the average: -1 The average of the 3 values input is: 5.33 Another example run is below (user input in bold) Enter a value to include in the average: 2 Enter a value to include in the average: 4 Enter a value to include in the average: 6 Enter a value to include in the average: -1 The average of the 3 values input is: 4.00 Be sure to consider the case when a user does not input any values on which to compute the average (user input in bold) Enter a value to include in the average: 1 No values were input Consider a situation in which you are given a single penny on day 1, two pennies on day 2, 4 pennies on day 3, etc. Each day the number of pennies received is twice as the number of pennies received the day before. That is, at the end of day 1, you will have a single cent. By the end of day 2, you will have 3 cents, one cent from day 1 and the 2 cents that were received on day 2. At the end of day 3, you will have 7 cents, 3 cents from the previous two days and the 4 cents received on day 3 Write a program that asks a user how much money they would like to make. Then, using a while loop, determine how many days must pass before the user has accumulated the desired amount of money. Use print statements in the body of your loop to keep track of how much money is given on each day and how much money has currently accumulated. Example run (user input in bold) How much money do you want (in dollars)? 0.56 Day 1: Given $0.01, you now have $0.01 Day 2: Given $0.02, you now have $0.03 Day 3: Given $0.04, you now have $0.07 Day 4: Given $0.08, you now have $0.15 Day 5: Given 0.16, you now have $0.31 Day 6 Given $0.32, you now have $0.63 On day 6, you will have met (or exceeded) your request for $0.56 with a total of $0.63

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

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

When does the stated amount of a liability equal its present value?

Answered: 1 week ago