Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Temperature Converter (Java)

Description

Your objective is to create a Java program that facilitates the conversion between Celsius and Fahrenheit temperatures. The user should be able to choose the conversion direction (from Celsius to Fahrenheit or vice versa) and then input the temperature value for conversion.

For the sake of this challenge, you can use the following conversion formulas:

  • Celsius to Fahrenheit: (Celsius × 9/5) + 32
  • Fahrenheit to Celsius: (Fahrenheit - 32) × 5/9

Your program should:

  • Prompt the user to select a conversion direction.
  • Accept the temperature in the selected format.
  • Display the converted temperature.

Example

1: Celsius to Fahrenheit 2: Fahrenheit to Celsius Choose conversion direction: 1 Enter temperature in Celsius: 25 Temperature in Fahrenheit: 77.0

Hints

  1. Use Scanner class from the java.util package for user input.
  2. Ensure you handle potential exceptions or invalid inputs gracefully.

Constraints

  • The input temperature is a floating-point number in the range -273.15 (absolute zero) to 10^5.
  • You should round off the converted temperature to 2 decimal places.

Set forth into the world of Java and take on this enlightening challenge!