I need an expert to solve this problem please using c++ programming Use Branchin
ID: 3590944 • Letter: I
Question
I need an expert to solve this problem please using c++ programming
Use Branching to solve the following problem: You are trying to get enough change to make a dollar. You want to write a program that counts the amount of change input by the user have and tells you how far you are away from a dollar Sample Input 2 2 2 1 Sample Output: Input how many pennies, nickels, dimes, and quarters do you have? Pennies: 2 Nickels: 2 Dimes: 2 Quarters: 1 Your total change is: .35 cents You are 0.65 cents short of a dollarExplanation / Answer
#include <iostream>
using namespace std;
int main()
{
int p,n,d,q;
cout << "Input how many pennies, nickels, dimes, and quarters do you have? " << endl;
cin >> p >> n>>d>>q;
cout<<"Pennies: "<<p<<endl;
cout<<"Nickels: "<<n<<endl;
cout<<"Dimes: "<<d<<endl;
cout<<"Quarters: "<<q<<endl;
double total = p * 0.01 + n * 0.05 + d * 0.1 + q * 0.25;
cout<<"Your total change is "<<total<<" cents"<<endl;
if(total < 1)
cout<<"You are "<<(1-total)<<" cents short of a dollor"<<endl;
return 0;
}
Output:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.