Question: Write a program that will accept a monetary amount from 0.00 to 11.99. This can be a float value . Pass it to a method
Write a program that will accept a monetary amount from 0.00 to 11.99. This can be a float value . Pass it to a method that will generate the "Check Book" or Text version of the number and generate a C-String result. Display the value of the generated C-String. Loop unit I enter X to exit. Note you do not need to code for 100s or 1000s - only up to eleven dollars.
Create a C-string for the output amount and use C-string related methods for processing. This implies you will have the following:
#include
#include
You may need to create additional methods. That is your choice.
Example actions: Entering 8.51 displays "Eight dollars and 51 cents" built as a C-String.
Entering 9.12 displays "Nine dollars and 12 cents" I will not deduct for stating "One dollars" or "1 cents" as plural as I did in the Week 1 assignment.
This snippet may help:
float myMoney;
cin >> myMoney; int singles = int(myMoney);
int cents = int(round(100.00 * (myMoney - singles))); string centsS = to_string(cents); // string allowed for data conversion from int. Do not use to string to build the result.
Deliverable is a flowchart/pseudo code and CPP program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
