How to display arraylist in tabular form in the java console -


i want display data of arraylist student in tabular form. have code displays last set of data input in table. wrong code?

public class gradesummary extends student{      static arraylist<student> studentlist = new arraylist<student>();      @suppresswarnings("resource")     public static void main(string[] args){         student student = new student();          scanner in = new scanner(system.in);          (int x=0; x<=10; x++){             system.out.print("student name: ");             try {                     student.name = in.nextline();                 }              catch (exception e)                  {                     e.printstacktrace();                 }              system.out.print("section: ");             try {                     student.section = in.nextline();                 }              catch (exception e)                  {                     e.printstacktrace();                 }              system.out.print("midterm grade: ");             try {                     student.mgrade = in.nextdouble();                 }              catch (exception e)                  {                     e.printstacktrace();                 }              system.out.print("second quarter grade: ");             try {                     student.sqgrade = in.nextdouble();                 }              catch (exception e)                  {                     e.printstacktrace();                 }              system.out.print("final exam grade: ");             try {                     student.fegrade = in.nextdouble();                 }              catch (exception e)                  {                     e.printstacktrace();                 }               student.fgrade = (student.mgrade*1/5)+(student.sqgrade*3/10)+(student.fegrade*9/20);             studentlist.add(student);             in.nextline();         }         show(studentlist);     }      private static void show(arraylist<student> studentlist2) {         new student();         system.out.println("               name           section          midterm grade          second quarter grade         final exam grade         final grade     ");         (int i=0;i<=10;i++)         {             student student1 = studentlist.get(i);             system.out.println ("                      " +student1.name+ "          "+student1.section+"           "+student1.mgrade+"         "+student1.sqgrade+"        "+student1.fegrade+"       "+student1.fgrade+" " );         }       }               } 

this class student

public class student {  string name; string section; double mgrade; double sqgrade; double fegrade; double fgrade; } 

how can make table data straight? more organize?

how can make table data straight? more organize? this: enter image description here

you create 1 student , overwrite students data. must create new student after had inputs

    student.fgrade = (student.mgrade*1/5)+(student.sqgrade*3/10)+(student.fegrade*9/20);     studentlist.add(student);     student = new student();     in.nextline(); 

also remove new student() show. recommend use variable name.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -