October 2017
Beginner
318 pages
7h 26m
English
The first thing we need to do is set up some control flow. As I mentioned before, there's six possible cases, and it might be tempting to just set up six if statements for each possible pairing of input and output types. This would be a little unwieldy though, so I have a slightly different plan. Instead of handling a different case for each possible pairing of types, the first thing I'm going to do is convert whatever value our user has given as the initial temperature value to a Celsius value. After I've done this, we'll convert that Celsius value to whatever type the user was originally looking for. This can be done using the following code block:
System.out.print("Input type (F/C/K): "); inputType = reader.next().charAt(0); ...Read now
Unlock full access