| | |
java help for newbie
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Solved Threads: 0
need to have an input of money to pay for an item and amount given.
to return change due with denomination format:
_ 20 dollar bills
_ 10 dollar bills
_ 5 dollar bills
_ 1 dollar bills
_ quarters
_ nickels, dimes, pennies, etc.
so far i got this:
import java.util.Scanner;
public class Cashier
{
//*****************************************************************
// Creates change to be given to customer from cashier.
//*****************************************************************
public static void main(String[] args)
{
double a;
double b;
Scanner scan = new Scanner (System.in);
System.out.print ("Enter total amount
");
a = scan.nextDouble();
System.out.print ("Enter amount given
");
b = scan.nextDouble();
System.out.print ("Change
" + (b - a) );
}
}
to return change due with denomination format:
_ 20 dollar bills
_ 10 dollar bills
_ 5 dollar bills
_ 1 dollar bills
_ quarters
_ nickels, dimes, pennies, etc.
so far i got this:
import java.util.Scanner;
public class Cashier
{
//*****************************************************************
// Creates change to be given to customer from cashier.
//*****************************************************************
public static void main(String[] args)
{
double a;
double b;
Scanner scan = new Scanner (System.in);
System.out.print ("Enter total amount
");a = scan.nextDouble();
System.out.print ("Enter amount given
");b = scan.nextDouble();
System.out.print ("Change
" + (b - a) );}
}
•
•
•
•
Originally Posted by groove04
need to have an input of money to pay for an item and amount given.
to return change due with denomination format:
_ 20 dollar bills
_ 10 dollar bills
_ 5 dollar bills
_ 1 dollar bills
_ quarters
_ nickels, dimes, pennies, etc.
so far i got this:
import java.util.Scanner;
public class Cashier
{
//*****************************************************************
// Creates change to be given to customer from cashier.
//*****************************************************************
public static void main(String[] args)
{
double a;
double b;
Scanner scan = new Scanner (System.in);
System.out.print ("Enter total amount");
a = scan.nextDouble();
System.out.print ("Enter amount given");
b = scan.nextDouble();
System.out.print ("Change" + (b - a) );
}
}
You need to devise an algorithm to give the least number of coins when you get change from a note.
When you've got that then we shall sort out your program. :eek:
*Voted best profile in the world*
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Solved Threads: 0
import java.util.Scanner;
public class Cashier
{
//*****************************************************************
// Creates change to be given to customer from cashier.
//*****************************************************************
public static void main(String[] args)
{
double a;
double b;
Scanner scan = new Scanner (System.in);
System.out.print ("Enter Total Price: $");
a = scan.nextDouble();
System.out.print ("Enter Payment: $");
b = scan.nextDouble();
System.out.println();
System.out.println ();
System.out.println ("Total Price: $" + a);
System.out.println ("Your Payment: $" + b);
System.out.print ("Change: $" + (b - a) );
}
}
public class Cashier
{
//*****************************************************************
// Creates change to be given to customer from cashier.
//*****************************************************************
public static void main(String[] args)
{
double a;
double b;
Scanner scan = new Scanner (System.in);
System.out.print ("Enter Total Price: $");
a = scan.nextDouble();
System.out.print ("Enter Payment: $");
b = scan.nextDouble();
System.out.println();
System.out.println ();
System.out.println ("Total Price: $" + a);
System.out.println ("Your Payment: $" + b);
System.out.print ("Change: $" + (b - a) );
}
}
![]() |
Similar Threads
- java newbie (Java)
- Problems launching java source code (serious newbie, sorry! :( ) (Java)
- newbie... Java load large picture :) Lit'l help plez (Java)
- StringTokenizer (Java)
Other Threads in the Java Forum
- Previous Thread: No able to set the jpanel positions
- Next Thread: Java open internet browser
Views: 1569 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application apps arguments array arrays automation awt binary bluetooth businessintelligence busy_handler(null) card chat class classes client code collision component constructor database draw eclipse error event eventlistener exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me jar java javafx javamicroeditionuseofmotionsensor javaprojects jmf jni jpanel jtree julia link linux list loop machine map method methods mobile netbeans newbie nls number object oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms socket sort sortedmaps sql string swing test textfield threads time transfer tree unlimited webservices windows






