Home>

Enter your language here
Java while statement
Code

Since there is a problem that cannot be solved by studying java, I would appreciate a solution.
Problem description
↓
Declares a while statement that performs loop processing when the value of variable num is 100 or less.
In the processing of the while statement, add a numerical value to the variable num, and the value to be added adds the current loop count, and the first processing is +1
The second process is +2 The third process is +3 ... The variable value is displayed on the screen after the loop.
### Problems that occur
I'm in trouble because all five loop processing results are not displayed properly.
### Corresponding source code

import java.util.Scanner;
public class Main {
public static void main (String [] args) {
Scanner scan = new Scanner (System.in);
String text = scan.next ();
int num = Integer.parseInt (text);
int num1 = 0;
int num2 = 1;
while (num<= 100) {
num + = num1 + num2;
num ++;
}
System.out.println (num);
}
}

Please describe what you tried for the problem here.

I did some research on the internet, but I couldn't find a site to get clear tips.

Supplemental information (FW/tool version etc.)

Please provide more detailed information here.