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 28-Feb-2008, 12:42
Computeretard66 Computeretard66 is offline
New Member
 
Join Date: Feb 2008
Location: NYC
Posts: 4
Computeretard66 is on a distinguished road
Unhappy

Write a C++ program to implement a cash register program


Write a C++ program to implement a cash register program. The program will
prompt the user to enter an amount equal to the amount of a purchase. The
program will also prompt the user to enter an amount tendered. The program
will read values for each item.

The program will determine if the amount tendered was sufficient. If it
was not, the program will calculate the amount the customer is short in
his payment and print
"The Amount tendered was ****. The amount of the purchase was ****.
Please tender the additional amount of ***** ."

If the amount tendered was sufficient, the program will print
"The Amount tendered was ****. The amount of the purchase was ****.
The total amount of change to be returned to the customer is ******."

If the total amount to be returned is greater than zero, the program will
print the non-zero amount of each denomination to be returned.
Denominations will be in twenties, tens, fives, ones, quarters, dimes,
nickels, and pennies.

For example,

If the purchase price is $3.37 and the amount tendered is $50.00 the
program should print:

The Amount tendered was $ 50.00. The amount of the purchase was $ 3.37.
The total amount of change to be returned to the customer is $ 46.63.
This will be returned as
Twenties: 2
Fives: 1
Ones: 1
Quarters: 2
Dimes: 1
Pennies: 3

CSCI 135 Students:

You must have a class called Change which has one integer private members for the number of each denomination:

private:

numTwenties
numTens
numFives
numOnes
numQuarters
numDimes
numPennies

One functionality should be written to show the number of each denumination.

One functionality should be written to set each number to 0.

And another functionality that takes a parameter placeholder double which represents the amount to make
change for, and fills the number of each denomination correctly.
  #2  
Old 28-Feb-2008, 15:18
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 713
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: How do i program this??? anyone??


Here is a start for you:
CPP / C++ / C Code:
// Change.h
class Change
{ private:
    int numTwenties;
    int numTens;
    int numFives;
    int numOnes;
    int numQuarters;
    int numDimes;
    int numNickels;
    int numPennies; 
    
  public:
    Change();
    Change( double dollars );
    Change( int twenties, int tens, int fives, int ones, int quarters, int dimes, int nickels, int pennies );
    
    double AmountInDollars();
    void SetAmount( double dollars );

   // I would probably add a method for setting/getting each of the twenties/tens/etc.
    void SetTwenties( int twenties );
    int GetTwenties();
};

CPP / C++ / C Code:
// Change.cpp
// Default constructor
Change::Change()
{ SetAmount( 0.00 );
}

Change::Change( double dollars )
{  SetAmount( dollars );
}

void SetAmount( double dollars )
{ numTwenties = 0;
  numTens = 0;
  numFives = 0;
  numOnes = 0;
  numQuarters = 0;
  numDimes = 0;
  numNickels = 0;
  numPennies = 0;

  while( dollars >= 20.00 )
  { numTwenties++;
    dollars -= 20.00;
  }
  while( dollars >= 10.00 )
  { numTens++;
    dollars -= 10.00;
  }
  while( dollars >= 5.00 )
  { numFives++;
    dollars -= 5.00;
  }
  while( dollars >= 1.00 )
  { numOnes++;
    dollars -= 1.00;
  }
  while( dollars >= 0.25 )
  { numQuarters++;
    dollars -= 0.25;
  }
  while( dollars >= 0.10 )
  { numDimes++;
    dollars -= 0.10;
  }
  while( dollars >= 0.05 )
  { numNickels++;
    dollars -= 0.05;
  }
  while( dollars >= 0.01 )
  { numPennies++;
    dollars -= 0.01;
  }
}

double AmountInDollars()
{ return 20.0*numTwenties + 10.0*numTens + 5.0*numFives + numOnes + 0.25*numQuarters + 0.1*numDimes + 0.05*numNickels + 0.01*numPennies;
}
  #3  
Old 29-Feb-2008, 09:05
Computeretard66 Computeretard66 is offline
New Member
 
Join Date: Feb 2008
Location: NYC
Posts: 4
Computeretard66 is on a distinguished road

Re: Write a C++ program to implement a cash register program


OMG! ur so cool fakepoo! thanx dude! =)
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

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
Two-Tier data dissemination code installation problem nidhibansal1984 Computer Software Forum - Linux 6 16-Sep-2007 11:13
Text-Based Roulette Game mfm1983 C++ Forum 5 29-Nov-2006 13:20
BOOKEEPING program, HELP!! yabud C Programming Language 10 17-Nov-2006 04:48
Pipeline freeze simulation darklightred C++ Forum 6 27-Jul-2006 20:37
How to read particular memory location ? realnapster C Programming Language 10 10-May-2006 10:11

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

All times are GMT -6. The time now is 14:53.


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