Question

Convert Celsius to Fahrenheit. (Programming Exercise 2.1) or Convert Fahrenheit to Celsius. Write a program with...

Convert Celsius to Fahrenheit. (Programming Exercise 2.1) or Convert Fahrenheit to Celsius.

Write a program with reads a Celsius degree value from the console or a Fahrenheit degree value from the console , then converts it to Fahrenheit or Celsius and displays the result. The formulas for the conversion are as follows:

Fahrenheit = (9 / 5) * Celsius + 32

Celsius = (5/9) *(Fahrenheit -32)

Write this program in Java please

2 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class Temperature {
  
   public static void main(String[] args) {
      

       double tempFahrenheit;
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter the temperature in Fahrenheit: ");
       tempFahrenheit = sc.nextDouble();
       double tempCelcius = (tempFahrenheit - 32) * 5 / 9.0;
       System.out.println(tempFahrenheit + " in Fahrenheit is " + tempCelcius + " in Celsius");
      
      
       System.out.print("\n\nEnter the temperature in Celcius: ");
       tempCelcius = sc.nextDouble();
       tempFahrenheit = (32 + (tempCelcius * 9 / 5.0));

       System.out.println(tempCelcius + " in Celsius is " + tempFahrenheit + " in Fahrenheit");

   }
}
====================
See Output
1 import java.util.Scanner <terminated> Temperature [Java Application] /LibrarylInternet Enter the temperature in Fahrenheit:
Thanks, let me know if there is any concern, Please rate if you think its helpful

Add a comment
Know the answer?
Add Answer to:
Convert Celsius to Fahrenheit. (Programming Exercise 2.1) or Convert Fahrenheit to Celsius. Write a program with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT