scanner SC equal to new scanner how to write
Answers
Answer:
Scanner in = new Scanner(System.in);
Example: Scanner in = new Scanner("Hello Javatpoint");
Program:
import java.util.Scanner;
class MyClass {
public static void main()
Scanner myObj = new Scanner(System.in);
System.out.println("Enter name, age and salary:");
String name = myObj.nextLine();
int age = myObj.nextInt();
double salary = myObj.nextDouble();
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("Salary: " + salary);
}
}
Output:
Enter name, age and salary:
Mr.Zombie ( you have to type this)
15 ( you have to type this)
10000000 ( you have to type this)
Name: Mr.Zombie
Age: 15
Salary: 10000000
i hope this helps...plz mark as brainliest