0

I need some help in using Scanner to get input from the user

public class CelciusFahrenheitConv { public static void main(String[] args) { //!----Fahrenheit to Celsius float fahrenheit = 82; //ENTER THE FAHRENHEIT VALUE fahrenheit -= 32; fahrenheit /= 9; fahrenheit *= 5; System.out.println ("The Celsius Value Is: "+(Math.round(fahrenheit))); //!----Celsius to Fahrenheit float celsius = 28; //ENTER THE CELSIUS VALUE celsius *= 9; celsius /= 5; celsius += 32; System.out.println ("The Fahrenheit Value Is: "+(Math.round(celsius))); } } // I imported the java.util.Scanner and tried it but it's not working properly.

25th Dec 2016, 4:43 PM
Arun MV
Arun MV - avatar
1 Réponse
0
This is how it works Scanner x = new Scanner (System.in); x is just a name, it can be whatever you want System.out.println("enter a value"); float fahrenheit = x.nextFloat();
25th Dec 2016, 4:59 PM
kallzo
kallzo - avatar