Today we gonna see the while loop condition and scanner class details in this portion.
i make a condition to get the result when count <=5 continuely increment by to condition made false .
1.Intitially count is zero
2.when my count is less than or equal to 5
2.1.get mark
2.2.increment count by 1
2.3.go back to step 2.
3.stop
in the above case we need to give input mark to the jdk, while the program running,
so we add the Scanner (class) to the program, the scanner is another class file previously programmed by someone to get the input while the program running , so we don’t need to create new one to get the input while the program running. all we have to do just copy the class (Scanner) , that means import java.util.Scanner to the program.it add below the package.
package selva.day1;
import java.util.Scanner;
public class FebTest1 {
public static void main(String[] args) {
int count=0;
while(count<=5)
{
System.out.println(“entermarks”);
count=count+1;
Scanner sc= new
int mark=sc.nextInt();
}
}
}
result:
entermarks
1
Entermarks
2
Entermarks
3
Entermarks
4
Entermarks
5
Entermarks
6