You are trying to get enough change to make a dollar You wan

You are trying to get enough change to make a dollar. You want to write a program that counts the amount of change you have and tells you how far you are away from a dollar.

#include <iostream>
using namespace std;

int main() {

const double pennies = 0.01, nickels = 0.05, dimes = 0.10, quarters = 0.25;
double dollar = 1.0;
double total;

cout << \"Input how many pennies, nickels, dimes, and quarters do you have?\" << endl;

/* Type your code here. */

cout << \"You are \" <<<< \" cents short of a dollar \" ;

return 0;
}

Solution

#include <iostream>
#include <math.h>
#include <cmath>  
using namespace std;

int main() {

const double pennies = 0.01, nickels = 0.05, dimes = 0.10, quarters = 0.25;
double dollar = 1.0;
double total;
int p_count,n_count,d_count,q_count;

cout << \"Input how many pennies, nickels, dimes, and quarters do you have?\" << endl;

cin>> p_count;
cin>> n_count;
cin>> d_count;
cin>> q_count;

total = (p_count*pennies) + (n_count * nickels) + (d_count *dimes) + (q_count *quarters);

cout << \"you have amonut of change \" << total << endl ;

if (total < 1.0)
{
   cout << \"You are \" << abs(remainder(total,dollar)) << \" cents short of a dollar \" << endl;
}
else
{
cout << \"You are \" << dollar - (remainder(total,dollar)) << \" cents short of a dollar \" ;

}


   return 0;    
}

You are trying to get enough change to make a dollar. You want to write a program that counts the amount of change you have and tells you how far you are away f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site