Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old June 23rd, 2003, 01:13 PM
Registered User
 
Join Date: Jun 2003
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
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





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





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