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 :
I hope you guys can help me in this ..
Thanks in Advance
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 :
I hope you guys can help me in this ..
Thanks in Advance