I need some help in using Scanner to get input from the user | SoloLearn: Learn to code for FREE!

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.

12/25/2016 4:43:08 PM

Arun MV

1 Answer

New Answer

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();