Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 23rd, 2003, 01:13 PM
Registered User
 
Join Date: Jun 2003
Location: , , USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default C program Currency Converter

I need help with a homework problem. I have no C programming experience.

Here are the instructions:

Write a C program to calculate the change converter. Take input from the user for amount due and currency note. You are required to give back the balance amount in the least denomination (i.e. least amount of currency to be returned). The program must be able to calculate in dollars, quarter, dime, nickel and pennies.
Example
Amount Due = $25.52
Amount Given = $30.00
Balance Amount = $ 4.48
Given back in denomination as
$1 bill - 4 = 4.00
Quarters - 1 = 0.25
Dimes - 2 = 0.20
Pennies - 3 = 0.03
Hint:

Use mod function (%)

Can anyone please help!

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old July 1st, 2003, 01:21 PM
Authorized User
 
Join Date: Jun 2003
Location: , , USA.
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to natmaster Send a message via AIM to natmaster Send a message via MSN to natmaster
Default

here is a simple way to do that, but i will only write a little code since it is homework:
double amount;
int dollars=0,quarters=0,dimes=0,pennies=0;
//if there is at least 1 dollar
if(amount/1 >= 1) {
//turning the equation into an int chops off any excess
  dollars=(int)(amount/1);
//rest of the money to be processed by lower functions
  amount=amount%1;
}

now continue that if statement for each of the variables of money descending in value. (next do quarters and use amount/.25 as the equation)

----------------------------
http://aeonofdarkness.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Base Converter iceman90289 C++ Programming 1 July 9th, 2008 07:44 PM
converter anukagni ASP.NET 1.0 and 1.1 Basics 1 August 28th, 2006 07:43 AM
need free currency converter xml webservice(.Net)? ccc_storage ASP.NET 1.x and 2.0 Application Design 0 September 29th, 2004 02:24 AM
VB.net Currency Converter lgschulz VB.NET 3 July 28th, 2004 05:24 PM
Language Converter Sunbin PHP How-To 4 July 11th, 2004 10:26 PM



All times are GMT -4. The time now is 04:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.