I am ask to modify the code below to display the non-zero denomination s only, u
ID: 3613095 • Letter: I
Question
I am ask to modify the code below to display thenon-zero denominations only, using singular wordsfor single units like 1 dollar and 1 penny, and plural words formore than one unit like 2 dollars and 3 pennies.(Use 23.67 to testyour program.I Really don't understand the question , if some can giveme hint or a way to tackle this problem i will be rallygrateful.
THIS IS THE CODE TO MODIFY
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
double amount ;
cout <<"Enter the amount in double::";
cin >> amount;
int remainingAmount =static_cast<int>(amount * 100);
//find the number of one dollars
int numberOfDollars = remainingAmount / 100;
remainingAmount = remainingAmount % 100;
//find the number of quarters in the remainingamount
int numberOfQuarters = remainingAmount / 25;
remainingAmount = remainingAmount % 25;
//find the number of dimes in the remainingamount
int numbrOfDimes = remainingAmount / 10;
remainingAmount = remainingAmount % 10;
//find the number of nickels in the remainingamount
int numberOfNikels = remainingAmount / 5;
remainingAmount = remainingAmount % 5;
//find the number of pennies in the remainingamount
int numberOfPennies = remainingAmount;
//Display the results
cout << "Your amount " << amount<< " consist of " <<
" " << numberOfDollars << "dollars " <<
" " << numberOfQuarters << "quarters " <<
" " << numbrOfDimes << " dimes "<<
" " << numberOfNikels << "nickels " <<
" " << numberOfPennies << "pennies " ;
system("pause");
return 0;
}
Explanation / Answer
please rate - thanks the change has to be to this code, print the first line and theninstead of just printing the code I've highlighted in red add abunch of if statements fro each denomination (dollar,quarter...). if(denomination==0) coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.