//Input Number
System.out.print("Enter a number from 1-10: ");
words = input.next();
//Processing String
if(!words.equals(FLAG)){
while(!words.equals("1") && !words.equals("2") && !words.equals("3") &&
!words.equals("4") && !words.equals("5") && !words.equals("6") &&
!words.equals("7") && !words.equals("8") && !words.equals("9") &&
!words.equals("10")){
System.out.print("Please enter a number in integer form from 1-10: ");
words = input.next();
}
}
//Close Scanner
input.close();
//String to Integer
num = Integer.parseInt(words);
//Output Number
if(num >=1 || num <=10){
System.out.println("\nYour number is: " + num);
}
How could i change the while loop? What if the number range was from 1-100? IS there any way to shorten the processing string segment? The program needs to be able to handle string and integers.