Vid Gamer
16-02-04, 07:14
I'm having trouble getting the correct output of this C++ program. Here's the code:
#include<iostream.h>
int main()
{
const float QuarterNum = .25;
float QuarterNumSum;
const float DimeNum = .10;
float DimeNumSum;
const float NickelNum = .5;
float NickelNumSum;
const float PennyNum = .1;
float PennyNumSum;
float TotalDollars;
float TotalCents;
cout<<"Enter the amount of quarters. ";
cin>>QuarterNumSum;
cout<<"Enter the amount of dimes. ";
cin>>DimeNumSum;
cout<<"Enter the amount of nickels. ";
cin>>NickelNumSum;
cout<<"Enter the amount of pennies. ";
cin>>PennyNumSum;
TotalDollars = QuarterNum + DimeNum + NickelNum + PennyNum;
cout<<"Total is " <<TotalDollars<< "dollars and " <<TotalCents<< "cents."; endl;
return 0;
}
What I need to do is have it print "The total is _______ dollars and ________ cents." but I am having some trouble in doing that.
Would anyone know? :(
#include<iostream.h>
int main()
{
const float QuarterNum = .25;
float QuarterNumSum;
const float DimeNum = .10;
float DimeNumSum;
const float NickelNum = .5;
float NickelNumSum;
const float PennyNum = .1;
float PennyNumSum;
float TotalDollars;
float TotalCents;
cout<<"Enter the amount of quarters. ";
cin>>QuarterNumSum;
cout<<"Enter the amount of dimes. ";
cin>>DimeNumSum;
cout<<"Enter the amount of nickels. ";
cin>>NickelNumSum;
cout<<"Enter the amount of pennies. ";
cin>>PennyNumSum;
TotalDollars = QuarterNum + DimeNum + NickelNum + PennyNum;
cout<<"Total is " <<TotalDollars<< "dollars and " <<TotalCents<< "cents."; endl;
return 0;
}
What I need to do is have it print "The total is _______ dollars and ________ cents." but I am having some trouble in doing that.
Would anyone know? :(