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);
}
}