Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

7. Understand the challenges of multilingualism.

Answered: 1 week ago

Question

5. Give examples of variations in contextual rules.

Answered: 1 week ago