Write a C++ program that has a while-loop to loop indefinitely until an input of a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a C++ program that has a while-loop to loop indefinitely until an input of a value that is 0 or less. Hence, prompt user to enter a positive integer value and repeat as long as it is greater than 0. Here is start of the code 2 #include <iostream> #include <iomanip> 34 3 using namespace std; 4 5 6 int num; 7 8 9 19 int main() { int sum = 0; int count = 0; double average; When exit the loop, calculate and then display the average to 2 decimal places. Remember that the values for variables sum and count depends on how many values entered. Here is a sample run of the complete program Enter an integer : 8 Enter an integer : 10 Enter an integer : 9 Enter an integer : 7 Enter an integer : Enter an integer : 5 Enter an integer : -5 Average is 7.33 (Ctrl) Write a C++ program that has a while-loop to loop indefinitely until an input of a value that is 0 or less. Hence, prompt user to enter a positive integer value and repeat as long as it is greater than 0. Here is start of the code 2 #include <iostream> #include <iomanip> 34 3 using namespace std; 4 5 6 int num; 7 8 9 19 int main() { int sum = 0; int count = 0; double average; When exit the loop, calculate and then display the average to 2 decimal places. Remember that the values for variables sum and count depends on how many values entered. Here is a sample run of the complete program Enter an integer : 8 Enter an integer : 10 Enter an integer : 9 Enter an integer : 7 Enter an integer : Enter an integer : 5 Enter an integer : -5 Average is 7.33 (Ctrl)
Expert Answer:
Answer rating: 100% (QA)
You can achieve the desired functionality using a whileloop to continuously prompt the user ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these operating system questions
-
answer all questions as instructed below. attend all questions. 4 Computer Vision (a) Explain why such a tiny number of 2D Gabor wavelets as shown in this sequence are so efficient at representing...
-
answer all questions as instructed below. make sure you have attended all questions .Comparative Architectures (a) Describe the organisation of a two-level branch predictor that makes use of a global...
-
International Paper reported the following items for the current year: Sales = $3,500,000; Cost of Goods Sold = $1,250,000; Depreciation Expense = $170,000; Administrative Expenses = $150,000;...
-
Why is the passive voice acceptable, even desirable, in bad news messages when it's considered poor, impersonal writing in most other situations?
-
A standard electrochemical cell is made by dipping a silver electrode into a 1.0 M Ag solution and a cadmium electrode into a 1.0 M Cd2+ solution. a. What is the spontaneous chemical reaction, and...
-
Indicate the type of flow given by \(\phi=\sqrt{r} \cos (\theta / 2)\). Calculate and plot typical streamlines.
-
Enciso Corporation is preparing its cash budget for November. The budgeted beginning cash balance is $31,000. Budgeted cash receipts total $135,000 and budgeted cash disbursements total $141,000. The...
-
Draw the diagram in one color for the first move and then another color for the second move. 1. Move 1: Translate 5 units right and 1 unit up. Move 2: Rotate 90 clockwise around the origin. List the...
-
John Parsons (123-45-6781) and George Smith (123-45-6782) are 70% and 30% owners, respectively, of Premium, Inc. (11-1111111), a candy company located at 1005 16th Street, Cut and Shoot, TX 77303....
-
Tellers at Masvingo Retailers in Zimbabwe are expected to ensure that the money they collect during the day is equivalent to the value of the items that they have sold. What component of leadership...
-
A homogeneous disk of mass \(M=300 \mathrm{~g}\) and radius \(R=23.0 \mathrm{~cm}\) rotates with constant angular speed \(\omega_{0}=25.0 \mathrm{rad} / \mathrm{s}\) around a fixed vertical axis,...
-
The roller in the Fig. 12.1 6 consists of two mutually integral (i.e., welded) disks of the same material and density. The roller can rotate without friction around a fixed pivot coincident with the...
-
Consider two rods of equal length \(L=17.2 \mathrm{~cm}\) and masses \(M\) and \(3 M\) (with \(M=153 \mathrm{~g}\) ) glued to each other as in Fig. 12.16. The system of the two rods is constrained to...
-
Consider the homogeneous bar, of negligible cross section, mass \(M=1.333 \mathrm{~kg}\) and length \(L=60.0 \mathrm{~cm}\) in Fig.12.19 . It is constrained to rotate in a vertical plane about its...
-
A projectile of mass \(m=2.5 \mathrm{~kg}\) is shot tangentially (see Fig.12.19) at the edge of a ring having radius \(R=50 \mathrm{~cm}\) and whose mass is equal (within measurement errors) to that...
-
Suppose that the additional units of capital affect the marginal productivity of labor (labor). This is not unrealistic. Word processors increase the marginal productivity of secretaries. On the...
-
The trade-off theory relies on the threat of financial distress. But why should a public corporation ever have to land in financial distress? According to the theory, the firm should operate at the...
-
John Fuji (age 37) moved from California to Washington in December 2011. He lives at 468 Cameo Street, Yakima, WA 98901. John's Social Security number is 571-78-5974 and he is single. His earnings...
-
Mary paid $2,000 of state income taxes in 2012. The total sales tax she paid during 2012 was $5,500, which included $3,000 for the cost of a new car. How should Mary treat the taxes paid on her 2012...
-
Lisa Sizemore, a taxpayer in the 10-15 percent tax bracket, purchased stock as an investment on July 11, 2011. She sold the stock on July 9, 2012, 2 days before qualifying for the long-term holding...
-
There is another possible explanation for purchased goodwill appearing in a sole proprietor's statement of financial position. What do you think it might be?
-
Why do the assets need to be revalued in these cases? The business has not been sold.
-
The shown partners have always shared profits and losses in the ratio: Holt 4; Stott 2: Young 1. From 1 January the assets were to be revalued as the profit sharing ratios are to be altered soon. The...
Study smarter with the SolutionInn App