Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can anyone help me with my beginning Java programing question? 1. Temperature Co

ID: 3667956 • Letter: C

Question

Can anyone help me with my beginning Java programing question?

1. Temperature Conversion using Java:
Write a user friendly program that

(a) Asks the user to enter temperature in Celsius (°C) which is then stored in a variable. Calculate the equivalent temperature in Fahrenheit (F) and display the result as follows

___ C is equivalent to ___ F


(b). After displaying the above result, the program now asks the user to enter temperature in Fahrenheit (F) which is then stored in a “separate” variable. Calculate the equivalent temperature in Celsius (C) and display the result as follows

___ F is equivalent to ____ C


Hint:

- Logically decide the datatype of variables being used

- Celsius and Fahrenheit temperature (T) relationship is given by

T (°F) = T (°C) × 1.8 + 32

Explanation / Answer

import java.util.*;
import java.lang.*;
import java.io.*;

class Conversion
{
   public static void main (String[] args) throws java.lang.Exception
   {
   double temperatueF1,temperatueC1,temperatueF2,temperatueC2;
    Scanner in = new Scanner(System.in);    

    System.out.println("Enter temperatue in Celsius");
    temperatueC1 = in.nextDouble();
    temperatueF1 = temperatueC1 * 1.8 + 32;
    System.out.println(temperatueC1 +" C is equivalent to " + temperatueF1+" F");

    System.out.println("Enter temperatue in Fahrenheit");
    temperatueF2 = in.nextDouble();
    temperatueC2 = ((temperatueF2 - 32))/1.8;
    System.out.println(temperatueF2 +" F is equivalent to " + temperatueC2+" C");
   }
}

-------------------------

output

Enter temperatue in Celsius: 212
212.0 C is equivalent to 413.6 F
Enter temperatue in Fahrenheit: 212
212.0 F is equivalent to 100.0 C

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote