Design and Develop a java program to read different inputs in a single line and print in separate lines.
Program Code:
import java.util.*;
import java.io.*;
class Diff
{
Public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter Emp name,age,sal”);
String str=br.readLine();
StringTokenzier st=new StringTokenzier(str,”,”);
String s1=st.nextToken();
String s2=st.nextToken();
String s3=st.nextToken();
String name=s1;
Int age=Integer.parseInt(s2);
float sal=float.parseFloat(s3);
System.out.println(“ Emp name is”+name);
System.out.println(“ Emp age is”+age);
System.out.println(“ Emp sal is”+sal);
}
}
Output:
Enter Emp name,age,sal
Neha,37,17000
Emp name is Neha
Emp age is 37
Emp sal is 17000.0
Post A Comment:
0 comments: