import java.util.*;import java.util.Scanner; public class AssertionExample{ public static void main( String args[] ) { Scanner scanner = new Scanner( System.in ); System.out.print( "Enter a number between 0 and 20: " ); int value = scanner.nextInt();
---Code here---
"Invalid number: " + value; System.out.printf( "You have entered %d\n", value ); }}In the code above, when the user enters the number, the scanner.nextInt() method reads the number from the command line. In the blank line provided, create an assert statement that determines whether the entered number is within the valid range (between 0 and 20). If the user entered a number that is out of range, then the "Invalid number" error should occur.
What will be an ideal response?
assert( value >= 0 && value <= 20 );
You might also like to view...
A PrintWriter buffers the values written to it until its buffer gets full.
Answer the following statement true (T) or false (F)
rue or false: The MAC address on a Windows computer can be accessed by typing ipconfig /all at the command prompt.
a. True b. False
You can use the ____ command to fix problems in the file system.
A. fdisk B. traceroute C. ping D. tune2fs
In a ____ traversal of a binary tree, for each node, first the left subtree is visited, then the right subtree is visited, and then the node is visited.
A. preorder B. inorder C. postorder D. recursive