Computer Science, asked by judekassem, 5 hours ago

Write a small basic program that asks the user to enter a score with the minimum value being 4 and the maximum value of 20; use in your program a data control that allows you to repeat the entry as long as it is invalid

Answers

Answered by xospheregaming
0

Explanation:

```

import java.util.Scanner;

class Program {

public static void main(String[] args) {

 // Create scanner object.

 Scanner s = new Scanner(System.in);

 // Create an infinite loop

 while (true) {

  // Ask the user for input

  System.out.print("Enter a number >= 4 and <= 20 : ");

  // Store the input in the variable 'num'

  int num = s.nextInt();

  // Check the condition

  if (!(num >= 4 && num <= 20)) {

   // If number is not >= 4 and <= 20:

   // then break this loop and exit

   // the program.

   break;

  }

 }

}

}

```

Similar questions