1 Using System.in
java.lang
System
PrintStream InputStream
print() read()
println()
System.out.println();
out is the reference variable of PrintStream Class
System.in.read() :-
in is the reference variable of InputStream Class.
read() has two major limitation
1) throw Exception
2) return byte data for single char
these problem has been solved by Scanner class because Scanner convert input data into Object pattern.
Scanner sc = new Scanner(System.in);
this class provide predefine method to typecast data into different datatype.
int a = sc.nextInt();
float b = sc.nextFloat();
String s = sc.next();
char ch = sc.next().charAt(0);
double d = sc.nextDouble();
ASSIGNMENT:-
WAP to create Salary Calculator where basic,ta,da,comm,pf,leave,advance salary will be entered by the user .display Gross Salary and Net Salary of employee.
WAP to reverse five digit number where first and last digit will be same .(without loop)
45123 o/p 42153
WAP to convert temperature from Celsius to Fahrenheit ?
2 Using Command Line
java.lang
System
PrintStream InputStream
print() read()
println()
System.out.println();
out is the reference variable of PrintStream Class
System.in.read() :-
in is the reference variable of InputStream Class.
read() has two major limitation
1) throw Exception
2) return byte data for single char
these problem has been solved by Scanner class because Scanner convert input data into Object pattern.
Scanner sc = new Scanner(System.in);
this class provide predefine method to typecast data into different datatype.
int a = sc.nextInt();
float b = sc.nextFloat();
String s = sc.next();
char ch = sc.next().charAt(0);
double d = sc.nextDouble();
ASSIGNMENT:-
WAP to create Salary Calculator where basic,ta,da,comm,pf,leave,advance salary will be entered by the user .display Gross Salary and Net Salary of employee.
WAP to reverse five digit number where first and last digit will be same .(without loop)
45123 o/p 42153
WAP to convert temperature from Celsius to Fahrenheit ?
2 Using Command Line
POST Answer of Questions and ASK to Doubt