Computer Science, asked by Bhumi1139, 1 year ago

Using switch write a menu driven program to convert celcius to farenhiet and vice versa if wrong choise is given display an error message

Answers

Answered by priyanshutry08
7

public static void main(String[] args)

{

   double Degrees_F,f,F;

   double DegreesC,c,C;

   double x;

   int temp;


   Scanner keyboard = new Scanner(System.in);


   System.out.println("Enter temperature ");

   x=keyboard.nextInt( );


   System.out.println("Enter C or c for Celcius or an F/f for Fahrenheit");

   temp=keyboard.nextInt( );


   switch (temp)

    {

   case 'C':


       Degrees_F = 9*(x/5)+32;

       System.out.println(x+"n Fahrenheit is"+Degrees_F);


       break;

   case 'c':

       Degrees_F = 9*(x/5)+32;

       System.out.println(x+"n Fahrenheit is"+Degrees_F);



    }






}

[hope it helps you]

Similar questions