Prompts the user for 4 one-word items and their corresponding prices in US dollars Compute the total price and displays a well-formatted receipt using manipulators. Task 1 Sample Output: Enter names of 4 one-word (maximum 10 letters) items to purchase: Yogurt Apple Butter Bread Enter their prices in US Dollars (<= $1,000): 0.75 8.00 12.99 2.85
Prompts the user for 4 one-word items and their corresponding prices in US dollars Compute the total price and displays a well-formatted receipt using manipulators. Task 1 Sample Output: Enter names of 4 one-word (maximum 10 letters) items to purchase: Yogurt Apple Butter Bread Enter their prices in US Dollars (<= $1,000): 0.75 8.00 12.99 2.85
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![Prompts the user for 4 one-word items and their corresponding prices in US dollars
Compute the total price and displays a well-formatted receipt using manipulators.
Task 1 Sample Output:
Enter names of 4 one-word (maxmum 10 letters) iteme to purchase:
Yogurt Apple Butter Bread
Enter their prices in US Dollars (<= $1,000):
0.75
8,00
12.99
2.85
Receipt
|Yogurt
Apple
Butter
|Bread
14
0.75]
8.00]
12.991
2.851
14
+-
---+
TOTAL: $
24.591
--+](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4441db9d-f1ff-481f-9b21-336372673504%2F97d5eeb8-0e85-4c20-af82-84f90d6ad33c%2F0wm0a88_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Prompts the user for 4 one-word items and their corresponding prices in US dollars
Compute the total price and displays a well-formatted receipt using manipulators.
Task 1 Sample Output:
Enter names of 4 one-word (maxmum 10 letters) iteme to purchase:
Yogurt Apple Butter Bread
Enter their prices in US Dollars (<= $1,000):
0.75
8,00
12.99
2.85
Receipt
|Yogurt
Apple
Butter
|Bread
14
0.75]
8.00]
12.991
2.851
14
+-
---+
TOTAL: $
24.591
--+

Transcribed Image Text:The text output of a program should be well-formatted for readability as well as displaying
numbers with the proper notation and precision levels. The default output formatting in C++ is
often not desirable, so one can add explicit instructions to the cout stream. These manipulators
and functions are defined in the <iomanip> library.
O setw (n): set the width (number of characters) of the next item to be at least n.
• If the next item width is less than n, then pad the item with extra spaces.
• If the next item width is greater than n, then the entire next item is output.
• left and right: when used in conjunction with setw (), justify the item to one side
forcing the padding to the other side. Note that these manipulators are persistent, i.e. remains
effective until the next change occurs.
• fixed: use the fixed-point notation (the decimal point notation that we are familiar with)
when displaying a numerical item. Note that fixed defaults to 6 decimal points if the data
type is float or double. See the example below:
int i = 123;
float f = 12.3;
float ff = 0.0001234;
double d = 10;
ble dd = 20.123456789o;
cout << £ixed;
cout << i < endl;
sout << E << endl;
Note the
roundine
// output: 123
// output: 12.300000
// output: 0.000123
// output: 10.000000
// output: 20.123457
cout << EE
cut << d << endl:
endl;
Note the
rounding
cout << dd << endl;
• setprecision (n) : when used in conjunction wvith fixed, set the number of digits after
the decimal point to n. Without fixed, the setprecision (n) will output n sigmificant
digits instead.
• showpoint: when printing a floating-point mumber, display the decimal point even if the
value is exactly equal to a whole number.
For setw (), setprecision (), showpoint, see example below:
float cost = 10.0;
cout << ":" < cost < ":" << endl;
cout << fixed << setprecision (2) < showpoint;
cout << right << ":" << setw (8) << cost << ":" << endl;
cout << ":" << setw(8) << "1234567" << ":" << endl;
The output would be as follows:
:10:
10.00:
: 1234567:
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY