Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: simple shopping cart

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 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$
    Buy something!

    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
    your order
    5 water @ 3$ = 15 $
    subtotal : 15.00 $ Tax @ 20 % : ..............


    please guy I need some help


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: simple shopping cart

    Do you have any specific questions about your assignment?
    Please post your code and any questions about problems you are having.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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);
                }
            }
    Last edited by Norm; January 12th, 2013 at 08:32 AM. Reason: added code tags

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: simple shopping cart

    You forgot to ask any specific questions about your code and the assignment. Please re-read Norm's post above.

Similar Threads

  1. Shopping cart application
    By ashkrish in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 28th, 2012, 01:40 PM
  2. Shopping cart application
    By ashkrish in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 28th, 2012, 12:08 PM
  3. Replies: 1
    Last Post: February 8th, 2012, 05:16 PM
  4. Simple Shopping Cart..... not so simple
    By jpsider in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 20th, 2012, 02:18 PM
  5. Need help with simple Shopping cart math
    By I hate Java! in forum Loops & Control Statements
    Replies: 3
    Last Post: November 6th, 2011, 10:46 PM

Tags for this Thread