What Is Fixed Point Notation
C++ Fixed Point Annotation
At that place are iii types of Nutrient at a Stadium.
1) Hotdog costs $5
two) Drink costs $4
3) Nacho Hats costs $12
Write a program that asks how many of each blazon of food were sold, then displays the amount of income generated from food sales. Format your dollar amount in fixed-point notation, with two places of precision, and exist sure to the decimal point it always displayed.
I need aid with the above question and how to use fix precision?
Thanks,
Kirk
Fixed betoken precision is just saying that the first northward digits of a number vest to the right side of the decimal betoken.
Your program expects n==2. So:
1234 ways 12.34
76 means 0.76
500 means 5.00
To get the whole part, use sectionalisation: 500 / 100 = 5.
To get the 'partial' office, use residual: 567 % 100 = 67.
To make C++ display things properly, you'll need the setw() and setfill() manipulators:
| |
Hope this helps.
[edit] Oh, don't forget to #include <iomanip>
Last edited on
Topic archived. No new replies allowed.
What Is Fixed Point Notation,
Source: https://cplusplus.com/forum/beginner/174328/
Posted by: boothfrass1954.blogspot.com
0 Response to "What Is Fixed Point Notation"
Post a Comment