-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.java
More file actions
51 lines (46 loc) · 1.5 KB
/
tests.java
File metadata and controls
51 lines (46 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.util.Scanner;
public class tests
{
public static int input = 0;
public static int rangeMin, rangeMax = -2147483648;
public static String stringInput = "yes";
public static Scanner scan = new Scanner(System.in);
public static void main()
{
while(stringInput.equals("yes"))
{
rangeMin = 0; rangeMax = -2147483648;
System.out.print("Enter the min: ");
rangeMin = scan.nextInt();
while (rangeMax < rangeMin || rangeMax == rangeMin || rangeMin + 1 == rangeMax)
{
System.out.print("Enter the max: ");
rangeMax = scan.nextInt();
}
intVerification(rangeMin, rangeMax);
System.out.println("The value is " + input);
scan.nextLine();
stringVerification();
}
}
public static int intVerification( int rangeMin, int rangeMax )
{
input = rangeMin - 1;
while( input > rangeMax || input < rangeMin )
{
System.out.print("Enter a value between " + rangeMin + " and " + rangeMax + ": ");
input = scan.nextInt();
}
return input;
}
public static String stringVerification()
{
stringInput = " ";
while( !stringInput.equals("yes") && !stringInput.equals("no") )
{
System.out.print("Enter yes or no: ");
stringInput = scan.nextLine();
}
return stringInput;
}
}