Question: DESCRIPTION Create a program that: 1) Asks the user for a temperature (allow decimal values). 2) Asks the user for the scale used for the

DESCRIPTION

Create a program that:

1) Asks the user for a temperature (allow decimal values).

2) Asks the user for the scale used for the temperature, Fahrenheit or Celsius, by entering either "F" or "C" (as a String)

3) Calculate the conversion of the given temperature to the other scale, e.g., if the user entered a Celsius temperature, calculate and print the Fahrenheit equivalent or vice-versa.

Recall the temperature conversion formulas:

F = 9/5 (C) + 32

C = 5/9 (F-32)

* Be careful to avoid integer division!

Sample output:

Enter a temperature: 80 Is that Fahrenheit (F) or Celsius (C)? F 80.0 degrees Fahrenheit is 26.666666666666668 degrees Celsius

STARTER CODE:

import java.util.Scanner;

public class TempConvert { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //ask the user for a temperature

//ask the user for the scale of the temperature

//convert to Celsius if given temperature was Fahrenheit //convert to Fahrenheit if given temperature was Celsius } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!