1. Member
Join Date
Nov 2008
Posts
2
Rep Power
0

## 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?
Last edited by Kristy; 11-18-2008 at 04:23 PM. Reason: Problem Solve~

2. 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

3. Member
Join Date
Nov 2008
Posts
2
Rep Power
0
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

4. the for statement work like this

Java Code:
```for(starting value, how long the value goes for, how to increment the value){
//stuff that needs the value goes in here
}```

5. 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

Did you read any document related to for loop. It's a simple thing if you read more about it.

Read this whole page first of all.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•