+ 2
Help me with this please
https://sololearn.com/compiler-playground/c7XfCA3r6DUo/?ref=app
5 odpowiedzi
+ 3
Below is your code - unmodified. I pasted it here to make it easier to discuss.
You are initializing AGE and SUM. But not doing anything else with those variables. Then you have a FOR loop which is set to run forever, as X is never going to be equal or less than 0. So there are several errors to overcome.
It is not clear what the goal of this program is, so I can't tell you what to fix. But I'm imagining that AGE and SUM need to be included inside the FOR loop somehow. Are you trying to increment AGE by the SUM? Are you trying to loop a certain number of times?
I assume you are trying to loop SUM number of times. So the for loop should have: x <= sum
Give us a better idea of what the program should actually produce / accomplish and we can advise in more detail.
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int age = sc.nextInt();
int sum = 1;
for(int x=1;x>=0;x++){
System.out.println(sum);
}
}
}
+ 2
do you know what this mean?
(int x=1;x>=0;x++)
an infinite loop;
you have `1` which is greater than `0`; and you add `1` more, so it is now `2`, which is more than `0`, and you add `1` again....
I hopr this helps
+ 2
So Mihaly Nyilas how am I going to solve it
+ 2
Tell us what the script is supposed to do. We will help you solve it.