Converting Decimal point string to Double or any other way?

Discussion in 'Java' started by bearzila, Aug 5, 2007.

  1. bearzila

    bearzila

    Joined:
    Aug 5, 2007
    Messages:
    1
    Location:
    Singapore
    Hey there , i am new to java for 3 weeks ryte now and i have assignment to Finish it up overall i am ok with java though, my problem is that how do i limit decimal point to #.## or 0.00 which is the same am i right?



    My assignment was to do a shopping cart i using switch cases instead of loops with if else.. but its come to the same ..

    the price is 0.02 per grams (paper) provided in the .class given


    before that here's is the class diagram:
    which name ShoppingCart.class


    ShoppingCart(name: String) <-- i name it as FishCart
    calculateTotalAmount(): double
    displayItemsInCart()
    printReceipt()



    case 4:

    System.out.println("Dear Customer Please enter 'T'(PrintReceipt) or 'F'(Discard Items) : ");
    String print = sc.next();
    sc.nextLine();

    if(print.equalsIgnoreCase("T"))
    {
    DecimalFormat df = new DecimalFormat("#.##");
    String a = df.format(FishCart.calculateTotalAmount());


    //not sure how minimise the decimal format on printreceipt and implement it.

    FishCart.printReceipt();

    System.out.println("Thank you for Shopping :)");
    System.out.println("System is exiting ...........");


    System.exit(0);

    }

    else if (print.equalsIgnoreCase("F"))
    {
    double RemovedGramz = 0.00;
    double RemovedLengthz = 0.00;

    /* cant seem to remove it. it show the display but the value is not cleared.
    how to check the think is removed?*/


    FishCart.removePaper(RemovedGramz);
    FishCart.removeRibbon(RemovedLengthz);
    System.out.println("Items Discarded");
    FishCart.displayItemsInCart();

    System.out.println("Thank you for Shopping :)");
    System.out.println("System is exiting ...........");

    System.exit(0);

    }
    break;





    this the preview :

    [​IMG]

    I hope you guys can help me in this ..

    Thanks in Advance
    bearzila, Aug 5, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. H aka N
    Replies:
    15
    Views:
    15,612
    Ben Jones
    Mar 2, 2006
  2. Roy J
    Replies:
    2
    Views:
    441
    Andrew Thompson
    Jul 11, 2004
  3. Sydex
    Replies:
    12
    Views:
    6,452
    Victor Bazarov
    Feb 17, 2005
  4. Saraswati lakki
    Replies:
    0
    Views:
    1,288
    Saraswati lakki
    Jan 6, 2012
  5. PERO
    Replies:
    4
    Views:
    446
    Brian McCauley
    Apr 13, 2007
Loading...

Share This Page