GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 17-Nov-2003, 11:27
milwalt milwalt is offline
New Member
 
Join Date: Nov 2003
Location: earth
Posts: 1
milwalt is an unknown quantity at this point

newbie help


I have just started to learn programming and i got this assignement. Please help

Write an interactive C++ program that determines the fewest of each money denomination required to make change using dollars, half dollars, quarters, dimes, nickels, and pennies. You must follow C++ standard.

INPUT : From the keyboard, name of the user and an integer representing the number of cents entered interactively.

OUTPUT : Display on the screen, the name of the user, the value of each denomination labeled For an input of 299 (cents) the output should be:


Example : Please type your name: John
Hello, John, Let’s compute the value of your change

2 dollars

1 half dollars

1 quarters

2 dimes

0 nickels

4 pennies
  #2  
Old 27-Dec-2003, 11:52
Erk102030 Erk102030 is offline
New Member
 
Join Date: Dec 2003
Posts: 1
Erk102030 is on a distinguished road

Try this.


Try this code:

CPP / C++ / C Code:
#include <iostream>
#include <stdlib.h>
#include <string.h>

using namespace std;

void printAll(int cent);


int main()
{
  string name;
  int cents;
  cout << "Please type your name:";
  cin >> name;
  cout << endl << "Hello " << name << " how much change do you have:";
  cin >> cents;
  printAll(cents);	
  return 0;
}



void printAll(int cents)
{
  int dollars;
  int hdollars;
  int quarters;
  int dimes;
  int nickels;
  int pennies;
  int crapvar;
  crapvar = cents%100;
  dollars = ((cents - crapvar)/100);
  cents = cents - (dollars * 100);
  crapvar = cents%50;
  hdollars = ((cents - crapvar)/50);
  cents = cents - (hdollars * 50);
  crapvar = cents%25;
  quarters = ((cents - crapvar)/25);
  cents = cents - (quarters * 25);
  crapvar = cents%10;
  dimes = ((cents - crapvar)/10);
  cents = cents - (dimes * 10);
  crapvar = cents%5;
  nickels = ((cents - crapvar)/5);
  cents = cents - (nickels * 5);
  pennies = cents;
  cout << "There are " << dollars << " dollars." << endl;
  cout << "There are " << hdollars << " half dollars." << endl;
  cout << "There are " << quarters << " quarters." << endl;
  cout << "There are " << dimes << " dimes." << endl;
  cout << "There are " << nickels << " nickels." << endl;
  cout << "There are " << pennies << " pennies." << endl;
  system("PAUSE");
}
 
 

Recent GIDBlogWelcome to Baghdad by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Linux] Top newbie questions. JdS Computer Software Forum - Linux 3 22-Jan-2004 12:00
total newbie need help grunt123 Apache Web Server Forum 2 04-Dec-2003 11:14
Newbie help, please Random C++ Forum 2 02-Dec-2003 12:05
newbie with stupid questions JUNK KED MySQL / PHP Forum 1 16-Oct-2003 08:58
Code problem (a newbie question) monkster87 C++ Forum 3 11-Aug-2003 12:46

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:23.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.