This is a question in Java. The project name of this exercise is WaterState Problem Description The purpose of this assignment is for you to write all of your own comments and code. You will also get some practice using enumeration. The detailed description of this problem comes from the Programming Exercise P3.9 that is in the book (page 126). \"Write a program that reads a temperature value and the letter C for Celsius or F for Fahrenheit. Print whether water is liquid, solid, or gaseous at the given temperature at sea level.\" You are to write a program that will take a temperature and units(Celsius or Fahrenheit). This temperature and units has the temperature as a double followed by either a \'C or an \'F\' for Celsius and Fahrenheit, respectively. Notice, that there is no space between the temperature and the units. Your program will then output one of three matter states, SOLID, LIQUID or GAS. Additionally, you should represent the state using an enumeration that contains the matter states SOLID, LIQUID and GAS. See special topic 5.4 (page 206) in the book.
public static void stateOfWater() {
System.out.println(\"Please enter a temperature value in Celsius or Fahrenheit : \");
Scanner s = new Scanner(System.in);
String[] argv = s.nextLine().split(\" \");
int temp = Integer.parseInt(argv[0]);
char tempType = argv[1].charAt(0);
switch (tempType) {
case \'C\':
if (temp <= 0) {
System.out.println(\"CELSIUS: Water is solid at \" + temp);
} else if (temp >= 100) {
System.out.println(\"CELSIUS: Water is gaseous at \" + temp);
} else {
System.out.println(\"CELSIUS: Water is liquid at \" + temp);
}
break;
case \'F\':
if (temp <= 32) {
System.out.println(\"FAHRENHEIT: Water is solid at \" + temp);
} else if (temp >= 212) {
System.out.println(\"FAHRENHEIT: Water is gaseous at \" + temp);
} else {
System.out.println(\"FAHRENHEIT: Water is liquid at \" + temp);
}
break;
}
}