TEMPERATURE CONVERTER ( JAVA ) ...

Hello Friends

How are you , i hope you all are fine , Btw today i make a temperature converter by using java . it take input from user and give your result, what you want .

If this is your assignment so this code (my code) was surely help you ..

  • THE CODE WAS GIVEN BELOW :-

import java.util.Scanner;

public class Main {

static float Fr(float F){

return (F*9/5)+32;

static float Cr(float C){

return (C-32)*5/9;

}

public static void main(String[] args) {

  Scanner sc = new Scanner(System.in);

  System.out.println(" • Enter '' true true '' for converting CELSIUS into FARANHEIT \n");

  System.out.println(" • Enter '' false false '' for converting FARANHEIT into CELSIUS \n");                                            

   boolean Celsius = sc.nextBoolean();             

   boolean FAHRENHEIT = sc.nextBoolean();

   if (Celsius==true){

    System.out.print("\n • Give the value for converting CELSIUS into FARANHEIT : ");

    float C = sc.nextFloat();

    System.out.println("\n");

    System.out.println("      \t         "+C+"°C"+" ~> "+Fr(C)+"°F\n");

    System.out.print("\n  \t ••• THANKS  FOR  USING  JAVA ••• \n\n\n\n");

   }

   else if(FAHRENHEIT==false){

    System.out.print("\n • Give the value for converting FARANHEIT into CELSIUS : ");

    float F = sc.nextFloat();

    System.out.println("\n");

    System.out.println("      \t         "+F+"°C"+" ~> "+Cr(F)+"°F\n");

    System.out.print("\n  \t ••• THANKS  FOR  USING  JAVA ••• \n\n\n\n");

    }  

   /* CREDITS :- MANDEEP YADAV */

}

}

  • Output :- 



  • You can simply copy the code and run ...
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-



Comments

Popular posts from this blog

1st Blog..