Click here to Skip to main content
15,905,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, the problem is to get student details and display the details of specific student in table format.
for ex:
Enter the number of student:
2(say)
Enter the details of student 1:
tom,science,90,80%,level8
Enter the details of student 2:
jerry,maths,80,85%,level9

Enter the level:
level8
The details are:
name subject marks percentage
tom science 90 80%

I am very new to java hence not able to figure out the logic to proceed ahead. Can you please help me in this. I am not able to get the user input as comma separated values in a single line and then print only those details of level 8 student in tabular form

What I have tried:

public class Student {

	public static void main(String[] args) throws IOException
	{
		int n;
		String name,subject,level,Student[],status1;
		float marks,percentage;		
		 BufferedReader br = new BufferedReader ( new InputStreamReader ( System.in ) );
		 System.out.println("Enter the number of student :");
		 String inputString1 = br.readLine();
		 n = Integer.parseInt ( inputString1 );
		 for(int i =0;i<n;i++){
		 System.out.println("Enter the Student "+(i+1)+ " details");
		 name = br.readLine();
		 subject = br.readLine();
		 level = br.readLine();
		 String inputString2 = br.readLine();
		 marks = Float.parseFloat(inputString2);
		 String inputString3 = br.readLine();
		 percentage = Float.parseFloat(inputString3);
		 Student c = new Student(name,subject,marks,percentage,level);
		 System.out.println(c);
		 }
		 System.out.println("Enter the level : ");
		 level = br.readLine();
		 System.out.println("The student details are");
		 String frmt= String.format("%-15s%-15s%-15s%-15s","Name","Subject","marks","percentage");
		    System.out.println(frmt);
		  
		    	
		    
	}

}
Posted
Updated 22-Dec-17 4:05am
v2

1 solution

The Java String class has many useful methods, such as String.split[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900