help with java programming..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • monkey1001
    New Member
    • Dec 2007
    • 10

    help with java programming..

    i have to write a program that will display the purchase,tender ed,change,dolla rs,Q,D,N,P
    the purchase & tendered has to be double and the number of coins have to be an int when i run the prgm it only asks me to enter purchase and tendered amount and thats it. it does not ask anything else it like skips everything else..anybody has an advice on how i can improve it pleaseee and thank u..

    [CODE=Java]import java.util.Scann er;
    public class Program2
    {
    public static void main(String[] args)
    {
    double purchase, tendered;
    int change, dollars, quarters, dimes, nickels, pennies;
    Scanner keyboard=new Scanner(System. in);
    System.out.prin tln("Enter amount of purchase: ");
    purchase=keyboa rd.nextDouble() ;
    System.out.prin tln("Enter amount tendered: ");

    change = tendered - purchase;
    dollars = (int) (change / 100);


    System.out.prin tln("Your change is: " + change);
    System.out.prin tln("The number of dollars is: " + dollars);
    System.out.prin tln("The number of quarters is: "+ quarters);
    System.out.prin tln("The number of dimes is: " + dimes);
    System.out.prin tln("The number of nickels is: " + nickels);
    System.out.prin tln("The number of pennies is: " + pennies);

    }
    }[/CODE]
    Last edited by BigDaddyLH; Jan 31 '08, 03:37 PM. Reason: quote tags were mistakenly used instead of code tags.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    1.) Please use code tags when posting code.
    2.) Have you compiled an run your program? Does it work in all situations?

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      I think I answered this question on Sun's Java forum: use ints, not doubles.

      Comment

      Working...