temperature program with inputs
This program asks you for your first and last name and then says hello, (first name, last name) and asks what the temperature is today. The temperature part is the problem i don't know how to do. I want it to ask for the temperature and if the number you give is greater than 72 to print a statement and if it is lower than 72 to print an alternate statement. Here is my code:
Code:
import java.io.*;
public class Greetingtemp {
public static void main(String args[]) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String firstName = "";
String lastName = "";
int w = Integer.parseInt();
while ("".equals(firstName)) {
System.out.print("PLEASE ENTER YOUR FIRST NAME: ");
firstName = in.readLine();
}
while ("".equals(lastName)) {
System.out.print("PLEASE ENTER YOUR LAST NAME: ");
lastName = in.readLine();
}
System.out.print("Hello " + firstName + " " + lastName);
System.out.print(", what is the temperature(F) today? ");
w = in.readLine();
if(w <= 72){
System.out.print("Maybe tomorrow will be nicer.");
}
else
System.out.print("Why are you still at your computer?");
}
}
This is what the compiler says:
Code:
Z:\java\Greetingtemp.java:9: cannot find symbol
symbol : method parseInt()
location: class java.lang.Integer
int w = Integer.parseInt();
^
Z:\java\Greetingtemp.java:23: incompatible types
found : java.lang.String
required: int
w = in.readLine();
^
2 errors