Results 1 to 3 of 3
  1. #1
    dcoi is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Exclamation JavaHelp (Discount Calculator)

    I'm trying to create a class that stores the number of units sold and has a method that returns the total cost of the purchase.

    It displays a small chart with the quantity and percent discount.

    I cant figure this out, can anyone help?





    below is the the code I have so far. :( :confused: :eek:



    import java.util.Scanner;

    public class salescommision
    {
    public static void main(String[] args)
    {
    double
    total = 99, //The total price before the offered discount was supposed to be 99$
    quantity,
    discount = 0,
    cost = (total-discount);


    Scanner keyboard = new Scanner(System.in);

    System.out.println("This program calculates the discounts "
    + "3 test scores.");


    System.out.print("Enter quantity: ");
    quantity = keyboard.nextDouble();



    total = (total * discount);
    System.out.println("The total is " + total);

    // The goal is if between these number of quantities you will get a certain percent discount
    if (total < 19)
    System.out.println("20%");
    else if (total < 49)
    System.out.println("30%");
    else if (total < 99)
    System.out.println("40%");
    else if (total < 100)
    System.out.println("50%");
    }
    }
    Last edited by dcoi; 02-24-2010 at 06:07 AM. Reason: typo

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    10

    Default

    1.) Please use code tags when posting code.
    2.) What happens when you attempt to compile/run your code and what did you expect instead?

  3. #3
    dcoi is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default

    :confused:The exact assignment is:

    A company sells a package for 99$. Quantity discounts are given according to the current table.

    Quantity Discount
    10-19 20%
    20-49 30%
    50-99 40%
    100 or More 50%

    Design a class that stores the number of units sold and has a method that returns the total cost of the purchase.






    My outcome is: (with 23 entered, but any # can be).

    Enter quantity: 23
    The total is 99.0
    20%


    I have to somehow make an if/else statement that calculates percentages and displays in the println? But I keep trying and failing, If you could help at all or lead me to a better direction I would really appreciate it.

Similar Threads

  1. I need Sun Voucher for discount price.
    By salma in forum Java Certification
    Replies: 2
    Last Post: 01-09-2010, 02:48 AM
  2. need help with my calculator
    By semoche in forum AWT / Swing
    Replies: 6
    Last Post: 12-04-2009, 11:16 PM
  3. Sun Java Exam Vouchers at 40% Discount! Validity-10th Nov
    By sudeepa@whizlabs.com in forum Reviews / Advertising
    Replies: 1
    Last Post: 07-14-2009, 01:10 PM
  4. JavaHelp
    By helloWorld564 in forum New To Java
    Replies: 4
    Last Post: 02-17-2009, 12:34 AM

Posting Permissions

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