Click here to Skip to main content
15,910,981 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
User input-

1>Coins of 1,5,10,25 Cents, i.e., penny, nickel, dime, and a quarter

2>Allow a user to select products Coke(25), Pepsi(35), Soda(45)

3>Return the selected product and remaining change if any


What I have tried:

I understood first 2 question answer but i don't understand 3rd Questioned

Kindly Inform
Posted
Updated 9-Sep-18 5:03am
Comments
Richard MacCutchan 9-Sep-18 10:41am    
It means that you need to return two variables to the caller of the routine or program. The selected product is the first item, and the coins/notes in change the second item.

Also you have tagged this question Java and PHP, but which language are you writing it in?

The user inputs a number of coins, which are mixed denominations. He selects a product which has a price.
You task is to check the total he entered against the product price and if he has paid enough subtract the price from the input total, and work out the minimum number of coins to return.
So if he enters two quarters, that's 50c. He selects a Pepsi, so you owe him 15c change. The smallest number of coins is a dime and a nickel.

Get the idea now?
 
Share this answer
 
Quote:
I understood first 2 question answer but i don't understand 3rd Questioned

How is it possible ? Never saw a vending machine ?
When you buy something in a machine, do you understand if the machine will give you change and how much ?
that is question 3.
 
Share this answer
 
v2
Comments
[no name] 9-Sep-18 14:47pm    
The 1 vote is basically ok, but without a comment it is basically not ok. So I try to compensate with my small 5
Patrice T 9-Sep-18 14:55pm    
Thank you.
The question look so obvious that it become difficult to explain, I tried to find an image that is universaly known.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900