Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Thien Huynh
- 01/28/2016
- World Temperature Calculator
- Converts degrees Celsius to degrees Fahrenheit */
- package worldtemperaturecalculator;
- import java.util.Scanner;
- public class WorldTemperatureCalculator {
- public static void main(String[] args) {
- // The multiplier used in conversion formula
- final double Multiplier = 1.8;
- // The offset used in conversion formula
- final double Offset = 32;
- // String to store city information
- String City;
- // double to store initial degrees Celsius
- double Celsius;
- // double to store resulting Fahrenheit conversion
- double Fahrenheit;
- // Scanner to obtain user inputs
- Scanner Inputs = new Scanner(System.in);
- // Ask the user what city
- System.out.println("What city do you live in?");
- // Store user input into the String City
- City = Inputs.nextLine();
- // Asks the user what is the temperature in Celsius there
- System.out.println("What is the temperature in Celsius there?");
- // Stores the temperature in the double Celsius
- Celsius = Inputs.nextDouble();
- // Calculate to Fahrenheit and store into the double Fahrenheit
- Fahrenheit = (Multiplier * Celsius) + Offset;
- // Closes the scanner
- Inputs.close();
- // Output the resulting conversion along with city
- System.out.println("The current temperature in " + City + " is " +
- Celsius + " ⁰C, which is " + Fahrenheit + " ⁰F");
- } // End of main()
- } // End of WorldTemperatureCalculator class
Advertisement
Add Comment
Please, Sign In to add comment