Computer Science, asked by nidhirs452, 1 day ago

write a algorithm enter 1 celsius to Fahrenheit if num 2 Fahrenheit to celsius​

Answers

Answered by samarthkrv
0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 System.out.print("Enter 1 for celsius to Fahrenheit conversion and 2 for Fahrenheit to celsius conversion:");

 Scanner sc = new Scanner(System.in);

 int choice = sc.nextInt();

     if(choice == 1){

         System.out.print("Enter value in celsius:");

         double cel = sc.nextDouble();

         double Fahrenheit = (1.8d*cel) + 32;

         System.out.println(cel + " in Fahrenheit is " + Fahrenheit);

     }

     else if(choice == 2){

         System.out.print("Enter value in Fahrenheit:");

         double Fahrenheit = sc.nextDouble();

         double celsius = (Fahrenheit - 32)*(0.555555556d);

         System.out.println(Fahrenheit + " in celsius is " + celsius);

     }

     else{

         System.out.println("Invalid entry: " + choice);

     }

}

}

Explanation:

Similar questions