422,764 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,764 IT Pros & Developers. It's quick & easy.

Is this mathematically possible? Java code for interest rate...

Dököll
Expert 100+
P: 2,364
Greetings and salutations!

Hope it's a good week thus far...

Got myself thinking and wanted to see what can be achieved with a certain bit of code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.    public double getPayment( ) {
  3.         double mPayment;
  4.  
  5.         mPayment = (loanAmount * interestRate)
  6.                            /
  7.                          (1 - Math.pow(1/(1 + interestRate),
  8.                                           numPayments ) );
  9.         return mPayment;
  10.     }
  11.  
  12.  
This calculates interest rate for a certain loan amount, per mothly payments. Question is can we turn around and doctor this up to calculate weekly payments as in instead of using it as interest rate, it is used as commission rate whereby the end result is a weekly reward on one's check for a certain amount of sales.

This is homework so I am not expecting the year book answer on this one, just a simple direction will do, surely can read between the lines;-)

I am almost satisfied with it thus far, and in due time I'll nail it right. I have since removed the code above and wanted to reinstate it only if in fact it is valuable, otherwise, will keep coding...

Perhaps this may me be of aid if you can tell me, here is an excerpt of the code above:

Expand|Select|Wrap|Line Numbers
  1. what is 1 in:
  2.  
  3. (1 - Math.pow
  4.  
  5. what is 1 in:
  6.  
  7. pow(1/
  8. what is 1 in:
  9.  
  10. (1 + interestRate
  11.  
  12.  
I think if I can at least figure that out, I'm on my way. What are you thoughts? Can this be done?

Thanks for your help;-)

Dököll
Feb 12 '08 #1
Share this Question
Share on Google+
14 Replies


BigDaddyLH
Expert 100+
P: 1,216
Aren't you just asking how to solve an equation for a certain variable? That's not particularly a Java question is it?
Feb 12 '08 #2

Dököll
Expert 100+
P: 2,364
Aren't you just asking how to solve an equation for a certain variable? That's not particularly a Java question is it?
Hey BigDaddyLH!

Thank you for coming to aid. It is a Java question, above is part of the code that caculates interest rate with monthly payments. I actually have more calculations I may need help with including:

Expand|Select|Wrap|Line Numbers
  1.  
  2.     public void setRate(double annualRate) {
  3.         interestRate = annualRate / 100.0 / MONTHS_IN_YEAR;
  4.     }
  5.  
  6.    //above sets the inerets rate, in my code it's the commission rate...
  7.  
  8.  
For something like that I would need to know what the 100.0 represents. I have already converted MONTHS_IN_YEAR to WORK_HOURS, annualRate, I believe is dayRate or something like that, seems to be working.

:-) I don't know math, I can also be way off...

Book's version of code and mine is too much to post here, will do if you wish...

I am hoping I can salvage some of the mathematic in the book's version to complete quicker or effortlessly.

If you are okay with chunks of the code, I keep posting.

Thanks again BigDaddyLH, for responding to this...

Dököll
Feb 13 '08 #3

BigDaddyLH
Expert 100+
P: 1,216
Expand|Select|Wrap|Line Numbers
  1.  
  2.     public void setRate(double annualRate) {
  3.         interestRate = annualRate / 100.0 / MONTHS_IN_YEAR;
  4.     }
  5.  
  6.    //above sets the inerets rate, in my code it's the commission rate...
  7.  
  8.  
For something like that I would need to know what the 100.0 represents.
I don't know if I'd call that a "Java question", but anyway, isn't 100.0 just converting from percentage to fraction? From 15 (percent) to 0.15? I can't imagine it's anything more than that.
Feb 13 '08 #4

Dököll
Expert 100+
P: 2,364
I don't know if I'd call that a "Java question", but anyway, isn't 100.0 just converting from percentage to fraction? From 15 (percent) to 0.15? I can't imagine it's anything more than that.
I was coming over to report I figured that part out, read the book a bit more, assume we have this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. package loanPackage;
  3.  
  4.  
  5. class Loan {
  6.  
  7.  
  8.     private final int MONTHS_IN_YEAR = 12;
  9.     private double    loanAmount;
  10.     private double    interestRate;
  11.     private int       numPayments;
  12.  
  13.  
  14.     public Loan(double amount, double rate, int period) {
  15.         setAmount(amount);
  16.         setRate  (rate  );
  17.         setPeriod(period);
  18.     }
  19.  
  20.  
  21.       public double getAmount( ) {
  22.         return loanAmount;
  23.     }
  24.  
  25.  
  26.     public int getPeriod( ) {
  27.         return numPayments / MONTHS_IN_YEAR;
  28.     }
  29.  
  30.  
  31.     public double getRate( ) {
  32.         return interestRate * 100.0 * MONTHS_IN_YEAR;
  33.     }
  34.  
  35.  
  36.     public double get_mPayment( ) {
  37.         double mPayment;
  38.  
  39.         mPayment = (loanAmount * interestRate)
  40.                            /
  41.                          (1 - Math.pow(1/(1 + interestRate),
  42.                                           numPayments ) );
  43.         return mPayment;
  44.     }
  45.  
  46.     public double getFinalPayment( ) {
  47.         double totalPayment;
  48.  
  49.         totalPayment = getFinalPayment( ) * numPayments;
  50.  
  51.         return totalPayment;
  52.     }
  53.  
  54.     public void setAmount(double amount) {
  55.         loanAmount = amount;
  56.     }
  57.  
  58.     public void setRate(double dayRate) {
  59.         interestRate = dayRate / 100.0 / MONTHS_IN_YEAR;
  60.     }
  61.  
  62.     public void setPeriod(int periodInDays) {
  63.         numPayments = periodInDays * MONTHS_IN_YEAR;
  64.     }
  65.  
  66.  
  67. }
  68.  
  69.  
I modified the code to make it fit what I need for the long run. This is actual code to calculate monthly payments on a loan and gives out the full amount to be paid for a certain amount of years.

Question is do you see any way this code can be used to calculate commission per hour worked and total amount of weekly pay for 40 hours:

(1) Hours replaces years
(2) Monthly payments replace daily commission pay

and so on... My professor will say I am making too much of this:-)

If you feel that logically it cannot be achieved, I'll stop now and run with my idea, same code but without all the math. Much appreciated assistance...

Dököll
Feb 13 '08 #5

BigDaddyLH
Expert 100+
P: 1,216
I guess I'm just confused about what you want to do. What does weekly pay have to do with interest payments? In any case, this is not a Java question.
Feb 13 '08 #6

Dököll
Expert 100+
P: 2,364
I guess I'm just confused about what you want to do. What does weekly pay have to do with interest payments? In any case, this is not a Java question.
You're toying with me:-)

I was turning the interest payments into commission payments, in fact, I have already completed my version of the code, it needs more work but I am almost there. Here's a better one for ya...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Can you help me doctor up an if statement?  I got below error:
  3.  
  4.     at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
  5.     at java.lang.Double.parseDouble(Unknown Source)
  6.     at loanPackage.LoanCalculator.getInput(LoanCalculator.java:70)
  7.     at loanPackage.LoanCalculator.start(LoanCalculator.java:33)
  8.     at loanPackage.LoanCalculator.main(LoanCalculator.java:20)
  9.  
  10.  
Here is the if statement:

Expand|Select|Wrap|Line Numbers
  1.  
  2. //Returns commission level for a certain percentage...
  3.  
  4.     public double getcommLevel( ) { 
  5.           double commmLevel;
  6.     if (getRate( ) <= 5) {
  7.         return commmLevel;
  8.     } else if (getRate( ) <=10) {
  9.         return commmLevel;
  10.     } else if (getRate( ) <= 15) {
  11.         return commmLevel;
  12.  
  13.     }
  14.  
  15.  
What I am trying to do now is load a weekly amount according to getcommLevel( ) , getRate will hold the interestRate keyed in by user:

Expand|Select|Wrap|Line Numbers
  1.  
  2.      //Returns the interest rate.
  3.     public double getRate( ) {
  4.         return interestRate * 100.0 * HOURS_WORKED;
  5.     }
  6.  
  7.  
What happens is commmLevel is underlined in red (through Eclipse) on each line in the code, seems to indicate it is undefined but as you can see double commmLevel; is there and decimals are being passed through.

What do you think may be happening?

Thanks!
Feb 14 '08 #7

BigDaddyLH
Expert 100+
P: 1,216
Expand|Select|Wrap|Line Numbers
  1. //Returns commission level for a certain percentage...
  2.     public double getcommLevel( ) { 
  3.           double commmLevel;
  4.     if (getRate( ) <= 5) {
  5.         return commmLevel;
  6.     } else if (getRate( ) <=10) {
  7.         return commmLevel;
  8.     } else if (getRate( ) <= 15) {
  9.         return commmLevel;
  10.     }
  11.  
The error should be obvious -- commmLevel is never given a value. For example, if getRate() is less than 5 what value will this method return? Undefined! What if the rate is between 5 and 10? Undefined! What if between 10 and 15? Undefined! What if over 15 (you forgot that case)? Control path doesn't even return a value!

You need to take a tutorial on the basics of programming because this code isn't properly thought out. Is this an introductory course you are taking?
Feb 14 '08 #8

Dököll
Expert 100+
P: 2,364
The error should be obvious -- commmLevel is never given a value. For example, if getRate() is less than 5 what value will this method return? Undefined! What if the rate is between 5 and 10? Undefined! What if between 10 and 15? Undefined! What if over 15 (you forgot that case)? Control path doesn't even return a value!

You need to take a tutorial on the basics of programming because this code isn't properly thought out. Is this an introductory course you are taking?
Wrong code, and excuse the late response:

Expand|Select|Wrap|Line Numbers
  1. //Returns commission level for a certain percentage...
  2.     public double getcommLevel( ) { 
  3.           double commLevel;
  4.     if (getRate( ) <= 5) {
  5.         return commLevel= 99.99;
  6.     } else if (getRate( ) <=10) {
  7.         return commLevel= 299.99;
  8.     } else if (getRate( ) <= 15) {
  9.         return commLevel= 399.99;
  10.     }
  11.  
  12.  
What I get with that is an underline part in my code, namely public double getcommLevel( ) { , this is keeping the code firing and giving the value as result.

the error says:

at sun.misc.FloatingDecimal.readJavaFormatString(Unkn own Source)
at java.lang.Double.parseDouble(Unknown Source)
at loanPackage.LoanCalculator.getInput(LoanCalculator .java:75)
at loanPackage.LoanCalculator.start(LoanCalculator.ja va:35)
at loanPackage.LoanCalculator.main(LoanCalculator.jav a:21)

it is defined as double< I am not sure that's even an issue.

What do you see?

Dököll
Feb 17 '08 #9

BigDaddyLH
Expert 100+
P: 1,216
I hope you realize you are reporting two different, unrelated problems. First, you forgot to return a value when the rate is above 15:
Expand|Select|Wrap|Line Numbers
  1. public double getcommLevel() {
  2.     if (getRate() <= 5) {
  3.         return 99.99;
  4.     } else if (getRate() <=10) {
  5.         return 299.99;
  6.     } else if (getRate() <= 15) {
  7.         return 399.99;
  8.     } else {
  9.         return 499.99;
  10.     }
  11. }
Second, you have some parsing error in another part of your code, line 75.
Feb 17 '08 #10

Dököll
Expert 100+
P: 2,364
I hope you realize you are reporting two different, unrelated problems. First, you forgot to return a value when the rate is above 15:
Expand|Select|Wrap|Line Numbers
  1. public double getcommLevel() {
  2.     if (getRate() <= 5) {
  3.         return 99.99;
  4.     } else if (getRate() <=10) {
  5.         return 299.99;
  6.     } else if (getRate() <= 15) {
  7.         return 399.99;
  8.     } else {
  9.         return 499.99;
  10.     }
  11. }
Second, you have some parsing error in another part of your code, line 75.
Works like a charm BigDaddyLH! Thanks much:-) Now can tell me why below wouldn't have worked:

Expand|Select|Wrap|Line Numbers
  1. //Returns commission level for a certain percentage...
  2.     public double getcommLevel( ) { 
  3.           double commLevel;
  4.     if (getRate( ) <= 5) {
  5.         return commLevel= 99.99;
  6.     } else if (getRate( ) <=10) {
  7.         return commLevel= 299.99;
  8.     } else if (getRate( ) <= 15) {
  9.         return commLevel= 399.99;
  10.     } else {
  11.        return commLevel= 499.99;
  12.     }
  13.     }
  14.  
  15.  
It got fuzzy the more I read into it. But commLevel seems to be legitimate.

Again, thanks, will post my reworking of the code mentioned above
Feb 19 '08 #11

BigDaddyLH
Expert 100+
P: 1,216
Works like a charm BigDaddyLH! Thanks much:-) Now can tell me why below wouldn't have worked:

Expand|Select|Wrap|Line Numbers
  1. //Returns commission level for a certain percentage...
  2.     public double getcommLevel( ) { 
  3.           double commLevel;
  4.     if (getRate( ) <= 5) {
  5.         return commLevel= 99.99;
  6.     } else if (getRate( ) <=10) {
  7.         return commLevel= 299.99;
  8.     } else if (getRate( ) <= 15) {
  9.         return commLevel= 399.99;
  10.     } else {
  11.        return commLevel= 499.99;
  12.     }
  13.     }
  14.  
  15.  
It got fuzzy the more I read into it. But commLevel seems to be legitimate.

Again, thanks, will post my reworking of the code mentioned above
That code "works" but it is poorly written. The insertion of the local variable commLevel doesn't serve any purpose. I think the code falls between two stools. You could have either written it to directly return values without the superfluous local variable:
Expand|Select|Wrap|Line Numbers
  1.     public double getcommLevel2() {
  2.         if (getRate() <= 5) {
  3.             return 99.99;
  4.         } else if (getRate() <=10) {
  5.             return 299.99;
  6.         } else if (getRate() <= 15) {
  7.             return 399.99;
  8.         } else {
  9.             return 499.99;
  10.         }
  11.     }
  12.  
Or you use the local variable to support a single exit point from the method:
Expand|Select|Wrap|Line Numbers
  1.     public double getcommLevel3() {
  2.         double commLevel;
  3.         if (getRate() <= 5) {
  4.             commLevel= 99.99;
  5.         } else if (getRate() <=10) {
  6.             commLevel= 299.99;
  7.         } else if (getRate() <= 15) {
  8.             commLevel= 399.99;
  9.         } else {
  10.             commLevel= 499.99;
  11.         }
  12.         return commLevel;
  13.     }
  14.  
This style is sometimes easier to work with in some debuggers, easier to add debugging print statements and sometime easier to understand program flow.
Feb 19 '08 #12

Dököll
Expert 100+
P: 2,364
That code "works" but it is poorly written. The insertion of the local variable commLevel doesn't serve any purpose. I think the code falls between two stools. You could have either written it to directly return values without the superfluous local variable:
Expand|Select|Wrap|Line Numbers
  1.     public double getcommLevel2() {
  2.         if (getRate() <= 5) {
  3.             return 99.99;
  4.         } else if (getRate() <=10) {
  5.             return 299.99;
  6.         } else if (getRate() <= 15) {
  7.             return 399.99;
  8.         } else {
  9.             return 499.99;
  10.         }
  11.     }
  12.  
Or you use the local variable to support a single exit point from the method:
Expand|Select|Wrap|Line Numbers
  1.     public double getcommLevel3() {
  2.         double commLevel;
  3.         if (getRate() <= 5) {
  4.             commLevel= 99.99;
  5.         } else if (getRate() <=10) {
  6.             commLevel= 299.99;
  7.         } else if (getRate() <= 15) {
  8.             commLevel= 399.99;
  9.         } else {
  10.             commLevel= 499.99;
  11.         }
  12.         return commLevel;
  13.     }
  14.  
This style is sometimes easier to work with in some debuggers, easier to add debugging print statements and sometime easier to understand program flow.
I see...

Boy you make it sound easy... Just finished it up, still weird in some spots. My first true design in Java actually:

(1) everything on paper to look at it
(2) a silly pseudocode to aid in the purpose of the code

I am not sure how I got the math to work my way, but I had an example of what commission pay should result to, I've manually caculated overtime payments, and when added into the program if it did not match my results on paper, back to square one. So excting though truly. Please tell me what else you see that could have been simpler. I know I went to far on this one:

Expand|Select|Wrap|Line Numbers
  1.  
  2. package burgersPackage;
  3.  
  4. /**
  5.  * @Lab 3
  6.  * @version 20080514
  7.  * @author :-)
  8.  * @Professor Jane Doe
  9.  * @param args
  10.  */
  11.  
  12. class MyJava_Burgers {
  13.     private double salesAmount;
  14.     private double commissionRate;
  15.     private double HOURS_WORKED_STANDARD = 40;
  16.  
  17.     private final double WAGE_RATE = 7.25;
  18.     private final double COMM_RATE_1 = 99.99;
  19.     private final double COMM_RATE_2 = 299.99;
  20.     private final double COMM_RATE_3 = 399.99;
  21.     private final double COMM_RATE_1_Low = 1.00;
  22.     private final double COMM_RATE_2_Low = 100.00;
  23.     private final double COMM_RATE_3_Low = 300.00;
  24.     private final double OT_WORKED_STANDARD = 1.5;
  25.  
  26.  
  27.     //Constructor: Initiating block...   
  28.     public MyJava_Burgers(double amount, double rate, double payHour) {
  29.         setAmount(amount);
  30.         setRate  (rate);
  31.         setHours  (payHour);
  32.     }
  33.  
  34.     //Returns the sales amount.
  35.     public double getAmount( ) {
  36.         return salesAmount;
  37.     }
  38.  
  39.     //Returns all hours worked.
  40.     public double getHours() {      
  41.  
  42.         return HOURS_WORKED_STANDARD;
  43.     }
  44.  
  45.  
  46.     //Returns Regular hours.
  47.     public double getRegHours() {      
  48.  
  49.         return getHours() - get_OT_Hours();
  50.     }
  51.  
  52.     //Returns overtime hours.
  53.     public double get_OT_Hours() {      
  54.         return loadHours() - 40;
  55.     }
  56.  
  57.     //Stimulates hours: not sure what happenned but I lost my thinking here:-)     
  58.     public double loadHours()  {
  59.         if (getHours() == 40) {
  60.             return HOURS_WORKED_STANDARD;            
  61.         } else if (getHours() < 40) {
  62.                 return HOURS_WORKED_STANDARD;
  63.         } else if (getHours() > 40) {
  64.             return HOURS_WORKED_STANDARD;
  65.         } else {
  66.                 return 0;
  67.             }
  68.     }
  69.  
  70.      //Returns the commission rate.
  71.     public double getRate() {
  72.         return commissionRate * 100.0 * 40;
  73.     }
  74.  
  75.     //Returns weekly regualr pay
  76.     public double getWeeklyPay() {
  77.         return WAGE_RATE * 40;
  78.     }
  79.  
  80.  
  81.     //Returns overtime pay
  82.     public double getOvertimePayRate() {
  83.         return WAGE_RATE * OT_WORKED_STANDARD;
  84.     }
  85.  
  86.  
  87.  
This is where it got confusing, so thanks on that. I switched it up a little bit...

Expand|Select|Wrap|Line Numbers
  1.  
  2.     //Captures commission rate and computes Commission level pay
  3.     public double getcomLevel() { 
  4.     if (getRate() == 5) {
  5.         return COMM_RATE_1;
  6.     } else if (getRate() < 5) {
  7.             return COMM_RATE_1_Low;
  8.     } else if (getRate() == 10) {
  9.         return COMM_RATE_2;
  10.     } else if (getRate() == 15) {
  11.         return COMM_RATE_3;    
  12.     } else if (getRate() <= 10) {
  13.         return COMM_RATE_2_Low;
  14.     } else if (getRate() <= 15) {
  15.         return COMM_RATE_3_Low;
  16.     } else {
  17.             return 0;
  18.   }
  19. }
  20.  
  21.  
  22.  
  23.     //Returns commission payment
  24.     public double get_commPayment() {
  25.         double commmPayment;
  26.         commmPayment = getRate() * salesAmount / 100.0;                 
  27.         return commmPayment;
  28.     }
  29.  
  30.     //Returns overtime payment
  31.     public double getOvetimePayment() {
  32.         double overtimePayment;
  33.         overtimePayment = get_OT_Hours() * getOvertimePayRate();                 
  34.         return overtimePayment;
  35.     }   
  36.  
  37.  
  38.     //Returns total weekly payment
  39.     public double getFinalPayment() {
  40.         double totalPayment;
  41.         totalPayment = getWeeklyPay() + get_commPayment() + getOvetimePayment();
  42.         return totalPayment;
  43.     }
  44.  
  45.     //Sets the sales amount of this sales.
  46.     public void setAmount(double amount) {
  47.         salesAmount = amount;
  48.     }
  49.  
  50.     //Sets the sales amount in hours.
  51.     public void setHours(double payHour) {
  52.         HOURS_WORKED_STANDARD = payHour;
  53.     }
  54.  
  55.     //Sets commission rate on sales.
  56.     public void setRate(double dayRate) {
  57.         commissionRate = dayRate / 100.0 / HOURS_WORKED_STANDARD;
  58.     }
  59.  
  60. }
  61.  
  62.  
This was the template. I adding it all here so you can run it and see... I think I'll just reply to this post to avoid problems:-)
Feb 21 '08 #13

Dököll
Expert 100+
P: 2,364
Expand|Select|Wrap|Line Numbers
  1.  
  2. package burgersPackage;
  3.  
  4. /**
  5.  * @Lab 3
  6.  * @version 20080514
  7.  * @author ...
  8.  * @Professor BenFoldsFive
  9.  * @param args
  10.  */
  11.  
  12. import javax.swing.*;
  13. import java.text.*;
  14.  
  15. class burgersCalculator {
  16.    // This object does the actual sales computation
  17.   private MyJava_Burgers myjava_burgers;
  18.  
  19.   public static void main(String[] arg) {
  20.  
  21.       burgersCalculator calculator = new burgersCalculator();
  22.       calculator.start();
  23.  
  24.   }
  25.  
  26.   public burgersCalculator() {
  27.  
  28.   }
  29.  
  30.   //Top-level method that calls other private methods
  31.   public void start() {
  32.  
  33.       describeProgram();   //tell what the program does
  34.       getInput();          //get three input values
  35.       displayOutput();     //display the results
  36.   }
  37.   // Provides a brief explanation of the program to the user.
  38.   private void describeProgram() {
  39.       System.out.println("This application calculates all sales amount per commission");
  40.       System.out.println("The application computes results into weekly pay and includes ovetime pay ");
  41.       System.out.println("We hope to gather Overtime payment + Commission + Regular pay in the end...");
  42.       System.out.println("Let us begin!");
  43.       System.out.println("\n");
  44.   }
  45.   //Displays the input values and weekly and total earnings.
  46.   private void displayOutput() {
  47.  
  48.       DecimalFormat df = new DecimalFormat("0.00");
  49.  
  50.       System.out.println("(1) Sales Amount is $ " + myjava_burgers.getAmount());
  51.       System.out.println("(2) Sales Commission Rate is "
  52.                           + myjava_burgers.getRate() + "%"); 
  53.       System.out.println("(3) Number of Overtime Hours "
  54.                       + myjava_burgers.get_OT_Hours( ) + " hours");
  55.       System.out.println("(4) Regular Hours  " + df.format(myjava_burgers.getRegHours()) + " hours");
  56.       System.out.println("(5) All Hours Worked Number is " + df.format(myjava_burgers.loadHours()) + " hours");
  57.       System.out.println("(6) Overtime Pay Amount $ "
  58.               + myjava_burgers.getOvetimePayment( ));
  59.       System.out.println("(7) Sales Commission Payment is $ " + df.format(myjava_burgers.get_commPayment( )));
  60.       System.out.println("(8) Regular Weekly Payment is $ " + df.format(myjava_burgers.getWeeklyPay( )));
  61.       System.out.println("    Total Weekly Payment is $ " + df.format(myjava_burgers.getFinalPayment()));                              
  62.  
  63.   }
  64.  
  65.   // Gets three input values--sales amount, interest rate, and
  66.   private void getInput() {
  67.       String inputStr;
  68.       double salesAmount, commissionRate, HOURS_WORKED_STANDARD;
  69.  
  70.       inputStr           = JOptionPane.showInputDialog(null,
  71.                                   "Sales Amount (Dollars + Cents):");
  72.       salesAmount         = Double.parseDouble(inputStr);        
  73.  
  74.       inputStr           = JOptionPane.showInputDialog(null,
  75.       "Daily Commission Rate (e.g., 9.5):");
  76.       commissionRate = Double.parseDouble(inputStr);
  77.  
  78.       inputStr           = JOptionPane.showInputDialog(null,
  79.                                   "Hours worked - # of hours:");
  80.       HOURS_WORKED_STANDARD = Double.parseDouble(inputStr);
  81.  
  82.  
  83.       //++++++++++++++++++++++++++++++
  84.       //DO NOT USE this while loop, it goes one for a while:-)
  85.       //This works but I get stuck there for some reason...
  86.  
  87.       //while (commissionRate < 5) {
  88.       //JOptionPane.showMessageDialog(null,
  89.       //"Invalid entry, please enter number greater or equal to 5"); 
  90.   //}
  91.       //create a new sales with the input values
  92.       myjava_burgers = new MyJava_Burgers(salesAmount, commissionRate, HOURS_WORKED_STANDARD);
  93.  
  94.   }
  95.  
  96.  
Let me know if you think this is Article material, if up to stuff, will pull it and add there, o at least ask someone, not sure if I can do that from here. Anyway, thanks much BigDaddyLH for everything. Let me know what you see need work.

In a bit!
Feb 21 '08 #14

Dököll
Expert 100+
P: 2,364
I figured this part out. I was not calling the input dialog after data did not take:

Expand|Select|Wrap|Line Numbers
  1.  
  2.      while (commissionRate < 5) {
  3.       JOptionPane.showMessageDialog(null,
  4.      "Invalid entry, please enter number greater or equal to 5"); 
  5.  
  6.       inputStr           = JOptionPane.showInputDialog(null,
  7.       "Daily Commission Rate (e.g., 9.5):");
  8.       commissionRate = Double.parseDouble(inputStr);
  9.   }
  10.  
  11.  
See yoo soon!

Dököll
Feb 21 '08 #15

Post your reply

Sign in to post your reply or Sign up for a free account.