Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Help needed with an discount class (Array)?

    import javax.swing.*;
    public class FindDiscount
    {
    public static void main(String []args)
    {
    final int NUM_RANGES = 5;
    int [] discountRangeLimit = { 1, 13, 50, 100, 200};
    double [] discountRate = { 0.00, 0.10, 0.14, 0.18, 0.20};
    double customerDiscount;
    String strNumOrdered;
    int numOrdered;
    int sub = NUM_RANGES - 1;
    strNumOrdered = JOptionPane.showInputDialog(null,
    "How many items are ordered? ");
    numOrdered = Integer.parseInt (strNumOrdered);
    while(sub >= 0 && numOrdered < discountRangeLimit[sub])
    --sub;
    customerDiscount = discountRate[sub];
    JOptionPane.showMessageDialog(null, "Discount rate for " +
    numOrdered + "items is " + customerDiscount);
    System.exit(0);
    }
    }

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    it compiles, it does wat seems to be logical from the classname. What is exactly the question you have?
    I am the luckiest man in the world


  •  

    Posting Permissions

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