20th Sep 2024, 7:09 PM
IFEANYICHUKWU HENRY
IFEANYICHUKWU HENRY - avatar
4 odpowiedzi
+ 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
20th Sep 2024, 7:21 PM
Mihaly Nyilas
Mihaly Nyilas - avatar
+ 2
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); } } }
20th Sep 2024, 7:39 PM
Jerry Hobby
Jerry Hobby - avatar
0
So Mihaly Nyilas how am I going to solve it
20th Sep 2024, 8:03 PM
IFEANYICHUKWU HENRY
IFEANYICHUKWU HENRY - avatar
0
Tell us what the script is supposed to do. We will help you solve it.
21st Sep 2024, 12:38 AM
Jerry Hobby
Jerry Hobby - avatar