You are here:

# C++/value of coins

Question
My problem is as soon as I think I understand C++ I get a problem like this that totally baffles me.  I don't know how to set this up to display the value in dollars and cents.

A bank teller needs a program to total the amount of money in his coin tray.  Write a program that asks the user to enter the number of each type of U.S. coin (half dollars, quarters, nickels, dimes, and pennies) and that displays the total value of the coins in dollars and cents.

Dear Jeffrey,
Thankyou for your question. Well, firt of all
don't be afraid of assignments, it will just
end your initial fear in any kind of language.

Jeffrey, i'm sorry but i cannot get your question
correctly. What i understood , i will try to help.
You have a program of a bank teller, who wants to
total any amount of money in coins.

Like if the user enters half dollars, it should be
added to coin total.

Well, let me help you with its algorithm, if i get
the problem correct.

1- Prompt the user for input
2- You need specific conversion formula's to first
convert the amount into coins.
3-You need to track what kind of money that user
entered, you can do it like this

output screen.
1- Enter '1' to enter the amount in dollars
2- Enter '2' to enter the amount in Half dollars

By this way atleast, you can find out how to interpret
the different money's and apply the specific changing
formula.
3- Then simply add the money to the total, you can
put the total counter to '0'.

I hope this helps, please try it, and if you find
any specific difficulty you can always tell me.

Regards,
Professional
Questioner's Rating
 Rating(1-10) Knowledgeability = 7 Clarity of Response = 5 Politeness = 10 Comment Thanks for the help, I saw the answer on C++ FAQ Lite, its to do with static function calls only being initialised once in function calls. Hence my calls to f(1) out put data and the f(2) and f(3) were never called. I think all you said in your response was correct but I was asking more about why the response was as it was.

• Ask a Question

C++

Volunteer

#### Professional

##### Expertise

I can answer any question about functions,pointers,structures,object oriented programming basics of classes and data structures.My strong field is structured programming.

##### Experience

I have got 2 years experiece under C . I am able to answer about the structured concepts pointers to a little extent,OOP concepts. I have also experience in data Strucutres like Linked List, Stacks , Queues, Heaps, B Trees, Red Black Trees. I will try to satisfy with my knowledge. I am the Student of an expert here Martin, what i have learnt today, i just owe my every knowledge to him. He is the greatest.