Chapter
Converting Units
From ComputerScienceOne by Dr Chris Bourke
Concepts
- How do you read numeric input from a user in Java with Scanner?
"Scanner s = new Scanner(System.in); The variable s is now active and can be read from. You can get specific values from the Scanner by calling various methods such as s.nextInt() to get an int, s.nex
- How do you design a Java program that converts Fahrenheit to Celsius?
"Let’s write a program that will prompt the user to enter a temperature in degrees Fahrenheit and convert it to degrees Celsius using the formula C = (F − 32) · 5/9.\n\nWe begin with the basic program
- Why must you use floating-point division when converting Fahrenheit to Celsius in Java?
"Try typing and running the program as defined above and you’ll find that you don’t get correct answers. In fact, you’ll find that no matter what values you enter, you get zero. This is because of the