I don’t know what initial values b
, x
, w
and y
got so I just initialized them somehow ..
But I think you want something like this:
public class HelloWorld{
public static void main(String []args){
int z = 26;
int b = 0;
int x = 1;
int w = 2;
int y = 1;
for (int i = 1;i<=z;i++) {
b = b+(b*y)+x+w;
if (i % 5 == 0)
System.out.println("In " + i + " years, IRA value: " + b);
}
System.out.print(z);
}
}
Output:
In 5 years, IRA value: 93
In 10 years, IRA value: 3069
In 15 years, IRA value: 98301
In 20 years, IRA value: 3145725
In 25 years, IRA value: 100663293
26
1
solved print the last line of a loop [closed]