This preview shows page 1. Sign up to view the full content.
Unformatted text preview: celsius = input.nextInt(); // calculate the result fahrenheit = ((celsius * 9) / 5) + 32; // print out the result System.out.printf("%d degrees Celsius = %d degrees Fahrenheit\n", celsius, fahrenheit); } // end of main } // end of class ConvertTemperature System.in - the name that Java gives to input received from the keyboard Scanner - a class provided by Java to help read information from the keyboard or files nextInt(); - the method to read a number from the keyboard // note how the variable name is used in these three spots. Scanner x; x = new Scanner(System.in); x.nextInt(); Questions about above code: What happens if we replace celsius = input.nextInt(); with input.nextInt();...
View Full Document
This note was uploaded on 12/27/2011 for the course CMPSC 5 taught by Professor Franklin during the Fall '09 term at UCSB.
- Fall '09