PCinvent.info

PCinvent Studio Template

Aug 16 2008
C++ Homework: Coins Change Print E-mail
Saturday, 16 August 2008


Read More Articles in: Technology>>>Programming

This Article is written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it


Time to post my old C++ homework. This one takes input and give changes in cents......

 

//File Name    :CentChanges.cpp
//Description    :This int main() take as input any change expressed in cents.
//Written by This e-mail address is being protected from spam bots, you need JavaScript enabled to view it

#include <iostream>
using namespace std;

int main(){
//Definition
int cent=0, remain=0;
double h_dollar=0, q_t=0, dime=0, nick=0, penny=0;

cout<<"Please input the cents"<<endl;
cin>>cent;
cout<<"You've input"<<cent<<"cents"<<endl;
cout<<endl<<"Thank you, here is your changes!"<<endl;

h_dollar = cent / 50;
cout<<"Half Dollar: "<<h_dollar<<endl;
remain = cent % 50;

q_t =  remain / 25;
cout<<"Quarter: "<<q_t<<endl;
remain %= 25;

dime = remain / 10;
cout<<"Dime: "<<dime<<endl;
remain %= 10;

nick = remain / 5;
cout<<"Nickels "<<nick<<endl;
remain %= 5;

penny = remain / 1;
cout<<"Pennies "<<penny<<endl;

return 0;
}//end of int main

Comments (0)Add Comment

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley
Smiley

busy
Tags:  Technology Programming C++ Homework Coins Change
Last Updated ( Saturday, 16 August 2008 )
 
< Prev   Next >
Site by PCinvent.com