Advertisement
Waliullah8328

Combination to Celsius and Farenheight

Feb 2nd, 2021
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class CelciousFarenheight {
  6.  
  7.     public static void Celsius(double x)
  8.     {
  9.         double cel = 0.55556 * (x-32);
  10.         System.out.println("Celsius temperature : "+cel);
  11.  
  12.     }
  13.  
  14.  
  15.  
  16.     public static void Fahrenheit(double x)
  17.     {
  18.         double F = 1.8 * x + 32;
  19.         System.out.println("Fahrenheit temperature : "+F);
  20.  
  21.     }
  22.  
  23.     public static void main(String[] args) {
  24.         Scanner input = new Scanner(System.in);
  25.         int n;
  26.         System.out.println("1. Fahrenheit to Celsius ");
  27.         System.out.println("2. Celsius to Fahrenheit ");
  28.         System.out.print("Please Enter Your Digit : ");
  29.         n = input.nextInt();
  30.         switch(n)
  31.         {
  32.             case 1:
  33.                 double a;
  34.                 System.out.print("Please Enter Your Fahrenheit temperature: ");
  35.                 a = input.nextDouble();
  36.                 Celsius(a);
  37.                 break;
  38.             case 2:
  39.                 double b;
  40.                 System.out.print("Please Enter Your Celsius temperature: ");
  41.                 b = input.nextDouble();
  42.                 Fahrenheit(b);
  43.  
  44.  
  45.         }
  46.     }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement