Solution | control
Console input has a System.in.read () in Java, but unlike Console.ReadLine () in C #, I don't know why, even if I use coercion type conversion in C #, I can't get the number I entered. That's because Java will enter the key to enter.
But there are solutions, and here's a small example of how to convert a gallon to a liter:
/*
* This is converte gallons to liters, users can input numbers.
*
* Call this program Galtolit2.java
*/
Import java.io.*;
Class GalToLit2
{
public static void Main (String args[])
Throws Java.io.IOException//use of System.in.read () required
{
double gallons;
Double liters;
SYSTEM.OUT.PRINTLN ("Change gallon to Liter");
The following is the processing of the input characters
BufferedReader in = new BufferedReader (new InputStreamReader (system.in));
System.out.print ("Please input gallons:");
gallons = double.parsedouble (In.readline ());
liters = gallons * 3.7854;
SYSTEM.OUT.PRINTLN (gallons + "gallons is" + liters + "liters.");
}
}