473,379 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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

Dököll
2,364 Expert 2GB
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
14 2293
BigDaddyLH
1,216 Expert 1GB
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
2,364 Expert 2GB
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
1,216 Expert 1GB
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
2,364 Expert 2GB
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
1,216 Expert 1GB
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
2,364 Expert 2GB
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
1,216 Expert 1GB
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
2,364 Expert 2GB
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
1,216 Expert 1GB
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
2,364 Expert 2GB
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
1,216 Expert 1GB
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
2,364 Expert 2GB
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
2,364 Expert 2GB
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
2,364 Expert 2GB
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

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

Similar topics

8
by: Travis Ray | last post by:
Hi, I just started a java class and I have this assignment and I'm stumped... I realize the code is messy... but I just started... so go easy on me :) Java Problem I am working on this...
0
by: Jason | last post by:
I need help designing a query (or two) in MS Access that will calculate a compounded rate of interest. This would be no problem using a simple FV function if the Interest Rate were constant....
2
by: phjones | last post by:
Need help programming mortagage calculator for 3 different loans 7 year, 15 year and 30 year. using java array I am a beginner with Java, This is what I have so far. Need to know if I am off the...
3
by: pnolan | last post by:
Hello there, I'm brand new to Java and have. I'm taking my 2nd Java class at school and I'm pretty lost at this point. The main problem I'm having right now is I cannot get my code to execute....
6
by: aureao4 | last post by:
I'm new to Java and programming. I'm trying to code a payroll program and continue getting errors. The program worked last week, this week I have to add set, get and a class. I've written the class...
1
by: lenin42001 | last post by:
Please can you help Have tried various means but cannot get this to work. The saver is prompted for the amount they wish to invest & a time period(in years) If initial investment is over Ł1000 & if...
3
by: zaidalin79 | last post by:
I have finally gotten my GUI to look like I want it to, but I am having trouble getting the calculations right. No matter what I put in there, it seems to calculate a large payment, and a very wrong...
0
by: Tom Gugger | last post by:
TOM GUGGER INDEPENDENT RECRUITER tgugger@bex.net 419-537-9447 SOFTWARE ENGINEER/ JAVA/ CONTRACT/ IN Must Be US Citizen All work On Site SOA Experience Preferred DOD experience Strongly...
2
by: fury30 | last post by:
this is the program as below and now what i need to do is add the following to it but i am not able to get how to do it # futval.py # A program to compute the value of an investment # ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.