Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
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
Old 10-28-2008, 12:19 PM   PM User | #2
Roelf
Senior Coder

 
Join Date: Jun 2002
Location: Zwolle, The Netherlands
Posts: 1,110
Thanks: 2
Thanked 28 Times in 28 Posts
Roelf is on a distinguished road
it compiles, it does wat seems to be logical from the classname. What is exactly the question you have?
Roelf is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:11 AM.


Advertisement
Log in to turn off these ads.