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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: