Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Atm Cash dispenser

843789Sep 16 2009 — edited Sep 17 2009
Can anyone help create a java program that if i input an amount, the program divides it in the the category of $50,$20 and $10. The ATM only Dispenses $50,$20,$10
Example:
Enter an Amount: $180
the out put would be
3 = Fifty's
1 = Twenty
1 = ten

// is there a way that if i Input an amount of $180 the out put would be, ATM only dispenses an amount of 50,20 and 10.
// 3 = fifty
// 1 = twenty
// 1= tens
// i dont know what to do to make a function to create this out put


// This is the original code
// the out put of this original code if i input $180 is
// 3 fifty , there is an error here
// 9 twenty
// 18 ten
//


package Withdraw;
import java.io.*;
class Withdraw
{
public static void main(String[] args) throws Exception
{
System.out.println ("Please Enter an Amount to Withdraw");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
if(n>5000)
System.out.println("ATM Cash Limit exceeds.");
else
{
if(n<5000)
System.out.println(n/50+ " Fifty");
System.out.println(n/20+ " Twenty");
System.out.println(n/10+ " Ten");
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 15 2009
Added on Sep 16 2009
10 comments
229 views