Can we use a user input to define what's it's category in an array ?
All I want is the user to type in a number ( a temperature in Celcius) like the code under, and the output would be a word from the array sorted out by few "if else". I'm begining and just trying to learn. import java.util.Scanner; class Program { public static void main(String[] args) { String[ ] myTemps = {"Cold", "Mild", "Warm", "Hot"}; int x = 0; Scanner thermometer = new Scanner(System.in); System.out.println("What is the temperature in celcius?"); int temperature = thermometer.nextLine(); //x = temperature; if(temperature > 0) { if(temperature > 15) { if(temperature > 30) { System.out.println(myTemps[3]);} else { System.out.println(myTemps[2]);} }else{ System.out.println(myTemps[1]);} }else{ System.out.println(myTemps[0]); } } }