float pennies = .1, nickels = .5,dimes = .10, quarters = .25;
float dollar = 1.00;
int totalamount;
cout << " please enter the number of change for\n";
cout << "pennies, dimes , nickels, quarters\n";
cout << "that will sum up to a dollar";
cin >> pennies >> dimes >> nickels >> quarters;
totalamount = pennies + dimes + nickels + quarters;
if ( totalamount == dollar)
{
cout << "congratulations that equals a dollar!\n";
}
else
{
cout << "sorry that does not equal one dollar\n";
}
.
int main()
{
float pennies, nickels, dimes, quarters ; // the cin sets the values of the variables
float dollar = 1.00 ;
int totalamount ;
cout << " please enter the number of change for\n" ;
cout << "pennies, dimes, nickels, quarters\n" ;
cout << "that will sum up to a dollar" ;
cin >> pennies >> dimes >> nickels >> quarters ; //
totalamount = (pennies * .01)+(nickels * .05)+(dimes * .10)+(quarters * .25) ; // the variables are set to how many there are not how much there worth
if (totalamount == dollar) //also could get rid of dollar variable and put just 1.00 here or even just 1
{
cout << "congratulations that equals a dollar!\n" ;
}
else
{
cout << "sorry that does not equal one dollar\n" ;
}
}