View Single Post
Old 10-28-2008, 11:45 AM   PM User | #1
The Big Boss
New to the CF scene

 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
The Big Boss is an unknown quantity at this point
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);
}
}
The Big Boss is offline   Reply With Quote