Results 1 to 3 of 3
  1. #1
    javanewbie20 is offline Member
    Join Date
    Apr 2011
    Rep Power

    Default discount program

    have this program to do for class tomoro need some urgent help

    Pricesmart Membership Club is giving a discount to its first 100 members of the day. The discount is calculated by a discount rate that is attached to a code given at the cashier. Write a program using the for loop to request from the user: number, name, total amount of bill and the code for the first 100 members. The program must calculate the total amount each member has to pay after the discount. Before the discount is calculated, VAT (15%) is added to the total amount of bill. The output is each memberís number, name, total amount of bill before VAT, total amount of bill after VAT, and amount of bill after discount. Under the heading Report 1, output the highest discount amount and the lowest discount amount. On a further report named Report 2, print the total discount amount that Pricesmart gave to its members.
    Use the following codes to calculate the accompanying discount amount as follows:

    Code Discount rate
    A 50%
    B 40%
    X 33%
    Y 25%
    Z 20%

    this is what i done so far

    Java Code:
     Scanner input = new Scanner(;
            int member_number, achar = 0;
            char a, b, x, y, z;
            String name, code;
            double total_bill = 0, vat_rate = 0.15, high = 0, low = 9999,
                    vat, discount = 0, total_bill_aftervat = 0 ,
                    bill_amount_afterdiscount = 0,highest = 0, lowest = 0,
                    total_payout_amount = 0;
            System.out.println("Please enter your member number");
            member_number = input.nextInt();
            for (int i = 1; i <= 5; i++) {
            System.out.println("Please enter your name");
            name =;
            System.out.println("Please enter the total amount of your bill");
            total_bill = input.nextDouble();
            System.out.println("Please enter your code");
            code =;
            vat = total_bill * vat_rate;
            total_bill_aftervat = total_bill + vat;
           char aChar = code.charAt(0);
           switch (achar) {
               case 'a': discount = total_bill_aftervat * 0.50;
               case 'b': discount = total_bill_aftervat * 0.40;
               case 'x': discount = total_bill_aftervat * 0.33;
               case 'y': discount = total_bill_aftervat * 0.25;
               case 'z': discount = total_bill_aftervat *0.20;
           bill_amount_afterdiscount = total_bill_aftervat - discount;
           if (discount < high) {
               highest = discount;
               if (discount > low) {
                   lowest = discount;
           total_payout_amount += discount;
           System.out.println("The member's number is : "+ member_number);
           System.out.println("The member name is : "+ name);
           System.out.println("The total bill amount before tax is : "+ total_bill);
           System.out.println("The total bill amount after vat is : "+ total_bill_aftervat);
           System.out.println("The total bill after discount is : "+ bill_amount_afterdiscount);
           System.out.println("Please enter your member number");
           member_number = input.nextInt();   
           System.out.println("Report 1");
           System.out.println("The highest discount is "+ highest);
           System.out.println("The lowest discount is "+ lowest);

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Richmond, Virginia
    Blog Entries
    Rep Power


    And what is your problem? All you did was give us the assignment and post your code so far. Ask specific questions about what you are stuck on if you want help.

  3. #3
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Destiny Islands
    Rep Power


    I have two suggestions:

    1) Post specific questions; we're not a homework service.
    2) Don't save your assignments for the night before, particularly if there's a concept in them that you struggle with.

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2011, 12:57 PM
  2. JavaHelp (Discount Calculator)
    By dcoi in forum New To Java
    Replies: 2
    Last Post: 02-24-2010, 10:32 PM
  3. I need Sun Voucher for discount price.
    By salma in forum Java Certification
    Replies: 2
    Last Post: 01-09-2010, 01:48 AM
  4. Sun Java Exam Vouchers at 40% Discount! Validity-10th Nov
    By in forum Reviews / Advertising
    Replies: 1
    Last Post: 07-14-2009, 01:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts