Thursday, August 15, 2013

Cents Converter




#include <iostream>
using namespace std;

//Named constants
const int HALF_DOLLAR = 50;
const int QUARTER = 25;
const int DIME = 10;
const int NICKEL = 5;

int main()

{

 //Declare variable
int cents;
int halfDollarReminder;


//display input field
cout << "Enter the amount of cents you want to convert: "<<endl;
cin >> cents;
cout << endl;

//display user input
cout << "The change you entered is " << cents<<"cents"< endl;




//calculate and display half dollar amount
cout << "The number of half-dollars to be returned is " << cents / HALF_DOLLAR << endl;
cents = cents % HALF_DOLLAR;

//display and calculate quarters amount
cout << "The number of quarters to be returned is "<< cents / QUARTER << endl;
cents = cents % QUARTER;

//display and calculate dimes amount
cout << "The number of dimes to be returned is "<< cents / DIME << endl;
cents = cents % DIME;



//display and calculate nickles amount
cout << "The number of nickels to be returned is "<< cents / NICKEL << endl;
cents = cents % NICKEL;

//display pennies amount
cout << "The number of pennies to be returned is "<< cents << endl;

system("pause");
 return 0;

}

No comments:

Post a Comment