Following is the decision program for a while loop
import java.util.Scanner;
class DecisionLoop {
public static void main(String[] args) {
int n;
Scanner input = new Scanner(System.in);
System.out.println("Input an integer");
while ((n = input.nextInt()) >= 50 && <=100) {
System.out.println("You have entered " + n);
System.out.println("You are passed");
}
System.out.println("its a fail");
}
}
What is a loop?
A "While" Loop is used to repeat a specific block of code an unknown number of times until a condition is met. For example, if we want to ask a user for a number between 1 and 10, we don't know how many times the user may enter a larger number, so we keep asking "while the number is not between 1 and 10."
A while loop is a loop that iterates through the code specified in its body, also known as a while statement until a predetermined condition is met. The loop ends if or when the condition is no longer met.
Hence to conclude the while loop is the one which is used with along the for
To know more on loops follow this link
brainly.com/question/15086216
#SPJ1
Explore all similar ans