• 11-18-2008, 04:29 PM
Kristy
Problem Solve~
Statement:

-Use while loop or for loop

-You are require to ask the user to enter their
~Annual Rate
~Total Investment
~Year Of Investment

-Then if the user enter 0 for either 1 above, display a error message says "Error".

-The formula is( i not sure correct anot also....):

Investment=(rate/100*investment*year)+investment

Here is what I had done:

import javax.swing.JOptionPane;
public class Haha{
public static void main (String[] args){
double investment=0.0,rate=0.0,year=0.0;

double rate=x,investment=y,year=z;

while if(x==0){
System.out.println("Error");
}else{
y=x/100*y*z+y
}
}
}

It's worng XD can anyone help me....please?
• 11-18-2008, 05:10 PM
Eranga
Did you compile and run the code? What happen if so? Copy-paste the error message here if you get any. No one here waiting to do your homework lol
• 11-18-2008, 05:19 PM
Kristy
okay...i juz figure out wat happen when i was still doing the code ....
I can't use while if and i think i'll be using if statement..cause I really have no clue on how to used the for(int i=1;i<=n;i++) concept Thanks Again! and I'll make sure to list the error next time too XD

• 11-18-2008, 06:17 PM
xcallmejudasx
the for statement work like this

Code:

```for(starting value, how long the value goes for, how to increment the value){ //stuff that needs the value goes in here }```
• 11-19-2008, 04:14 AM
Eranga
Quote:

Originally Posted by Kristy
okay...i juz figure out wat happen when i was still doing the code ....
I can't use while if and i think i'll be using if statement..cause I really have no clue on how to used the for(int i=1;i<=n;i++) concept Thanks Again! and I'll make sure to list the error next time too XD