nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Please help with this C++ problem

This is a discussion on Please help with this C++ problem within the Coding in General forums, part of the Development/Scripting category; Hi i would be glad if any body helps me to solve this. thanks Problem: In this program you need ...


Go Back   nixCraft Linux Forum > Development/Scripting > Coding in General

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 08-23-2007, 08:26 AM
Junior Member
User
 
Join Date: Aug 2007
My distro: Debian
Posts: 6
Rep Power: 0
oronno is on a distinguished road
Exclamation Please help with this C++ problem

Hi i would be glad if any body helps me to solve this. thanks

Problem:

In this program you need to write a program that program compute the number of coins of each kind required to make up certain amount of money given in dollars. The coins to be used are two dollar coins, one dollar coins, 50 cents, 20 cents, 10 cents, and 5 cents. You may need to use the round() function from cmath library.
This assignment will use separate compilation. You MUST use the following guidelines for the design of your program:
  1. Design a function int coinCompute(int coin, float amount, float& amountLeft). The function returns the maximum number of specified coins to make up a given amount to nearest 5 cents such that amount*100.0 = coinCompute(coin,amount,amountLeft)*coin + amountLeft*100.0. The first parameter coin indicates the coin, i.e. 200 for two dollar, 100 for one dollar, 50 for 50 cents, 20 for 20 cents, 10 for 10 cents, and 5 for 5 cents. The second parameter indicates money in dollars up to two decimal places. The third parameter indicates the money left after distributing the particular coin. Note that amountLeft can be negative, e.g. if amount = 0.08 and coin = 10 then the function return 1 with amountLeft = -0.02.
  2. Write an application program coinMain.cpp that uses the coinComputefunction to calculate the coin distribution of a given amount of money input by the user. The program must compute the highest number of coins for a higher valued coin.
Program should look like this when you run:
Please input the amount of money: 4.78
The coin distribution is as follows
Number of two dollar coins: 2
Number of one dollar coins: 0
Number of 50 cents: 1
Number of 20 cents: 1
Number of 10 cents: 1
Number of 5 cents: 0

Last edited by oronno; 08-23-2007 at 08:27 AM.. Reason: mistake
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-05-2007, 07:02 AM
wje_nc's Avatar
Junior Member
User
 
Join Date: Nov 2007
Location: Mariposa
My distro: Slackware 9.1
Posts: 3
Rep Power: 0
wje_nc is on a distinguished road
Default

Since this is obviously homework, it would be better if you post the code you have so far, and ask specific questions about its behavior.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +5.5. The time now is 02:59 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36