Java Program to get input from user
//Let's see the simple example of the Java Scanner class which reads the int, string and double value as an input:
//
import java.util.Scanner;
class abc{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter your rollno");
int rollno=sc.nextInt();
System.out.println("Enter your name");
String name=sc.next();
System.out.println("Enter your fee");
double fee=sc.nextDouble();
System.out.println("Rollno:"+rollno+" name:"+name+" fee:"+fee);
sc.close();
}
}
Enter your rollno
10
Enter your name
John
Enter your fee
20000
Rollno:10 name:John fee:20000.0
//Let's see the simple example of the Java Scanner class which reads the int, string and double value as an input:
//
import java.util.Scanner;
class abc{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.println("Enter your rollno");
int rollno=sc.nextInt();
System.out.println("Enter your name");
String name=sc.next();
System.out.println("Enter your fee");
double fee=sc.nextDouble();
System.out.println("Rollno:"+rollno+" name:"+name+" fee:"+fee);
sc.close();
}
}
Enter your rollno
10
Enter your name
John
Enter your fee
20000
Rollno:10 name:John fee:20000.0
0 comments:
Post a Comment