0
Hii Friends.. I am new at here... I have finishied the "Basic Concepts" and "if..else.." chapter.. I want to use the user input and if else statements in one programm.. evry time some error occures.. plzz help.. Thanks..!!
6 Respostas
+ 4
Here is an example:
import java.io.InputStream;
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter your age: ");
String age = scanner.nextLine();
System.out.println(age);
if (Integer.parseInt(age) < 18) {
System.out.println("Hello, boy.");
} else {
System.out.println("Hello, mister.");
}
}
}
+ 1
Show your code plz
0
The way zen showed it is a great example. just make sure with code playground, you import your scanner and input streamer if not it wont work.
0
but if you use eclipse you dont need to :)
0
Thank u friends...
your replies are motivation to me to learn java...
0
Thank u zen...