# simple shopping cart

• January 12th, 2013, 02:32 AM
dodda911
simple shopping cart
Dear Guys,
im very beginner in programming and I want to make a simple shopping cart as follows and a cant figure it out :

this program should allow the user to order from small catalogue then calculate the final bill including tax at 20 %. sample program should look like this:

our catalogue [ product code in brackets]:
1-water [k1234] 3\$
2-honey [k123] 2\$
3-meat [p123] 1\$

Enter order number (o to stop): k1234
Enter Quantity : 5
Enter order number (o to stop): 5667
Sorry I don't understand use product code only.
Enter order number (o to stop): 0
5 water @ 3\$ = 15 \$
subtotal : 15.00 \$ Tax @ 20 % : ..............

please guy I need some help
• January 12th, 2013, 06:37 AM
Norm
Re: simple shopping cart
```import java.util.Scanner; public class shop2 { {   public static void main(String[] args) {   Scanner in = new Scanner(System.in); int qty ; double k3876=3.00 ,p3487=2.50 ,z9983=12.75; String ordernumber ; boolean order =true; double total; System.out.println("Our catalogue [Product codes in brackets]"); System.out.println("(1) Condensed Powdered water [P3487], \$2.50 per packet."); System.out.println("(2) Distilled Moonbeans [K3876], \$3.00 for a dozen."); System.out.println("(3) Anti-Gravity Pills [Z9983], \$12.75 for 60."); System.out.println("Buy something!"); System.out.println("Enter order number!");   ordernumber = in.nextLine(); switch (ordernumber){ case "p3487": System.out.print("Enter Quantity: "); qty = in.nextInt(); total= (qty * p3487); System.out.println("nter Order Number (0 to stop)"); ordernumber =in.nextLine(); break; case "k3876": System.out.print("Enter Quantity: "); qty = in.nextInt();   break; case "z9983": System.out.print("Enter Quantity: "); qty = in.nextInt();   break; case "0": order = false; break; default: System.out.println("Sorry, I don't understand! Use Product Codes only."); break; } System.out.println("Your order: " + ordernumber); } }```