Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Java outputs student ID number, name, and grades
Java outputs student ID number, name, and grades

public?class?Student?{ private?int?kemu1,?kemu2,?kemu3,?kemu4,?kemu5; public?int?getKemu1()?{ return?kemu1; } public?void? setKemu1(int?kemu1)?{ this.kemu1?=?kemu1; } public?int?getKemu2()?{ return?kemu2; } public?void?setKemu2(int?kemu2)?{ this.kemu2?=?kemu2 ; } public?int?getKemu3()?{ return?kemu3; } public?void?setKemu3(int?kemu3)?{ this.kemu3?=?kemu3; } public?int?getKemu4()?{ return?kemu4; } public?void?setKemu4(int?kemu4)?{ this.kemu4?=?kemu4; } public?int?getKemu5()?{ return?kemu5; } public?void?setKemu5(int?kemu5)?{ this. kemu5?=?kemu5; }

}

The above is the Student class import?java.util.ArrayList;

import?java.util.Random;

public?class?Test?{ public?static?void?main(String[]?args)?{ ArrayList?list?=?new?ArrayList(); // ?Initialize results for?(int?n?=?0;?n?

Student?st?=?new?Student();

< p>st.setKemu1(new?Random().nextInt(100));

st.setKemu2(new?Random().nextInt(100));

st. setKemu3(new?Random().nextInt(100));

st.setKemu4(new?Random().nextInt(100));

st.setKemu5(new? Random().nextInt(100));

list.add(st); } //?Calculate the average grade int?avg?=?0; for?(int?n?=?0; ?n?

avg?+=?list.get(n).getKemu1();

avg?+=?list.get (n).getKemu2();

avg?+=?list.get(n).getKemu3();

avg?+=?list.get(n). getKemu4();

avg?+=?list.get(n).getKemu5(); } double?avg2?=?avg?/?20; System.out.println("Class average Score"?+?avg2); //?Calculate who wins for?(int?n?=?0;?n?

double?avg3;< /p>

int?avg4?=?0;

avg4?+=?list.get(n).getKemu1();

avg4?+=?list .get(n).getKemu2();

avg4?+=?list.get(n).getKemu3();

avg4?+=?list.get(n ).getKemu4();

avg4?+=?list.get(n).getKemu5();

avg3?=?avg4;

System .out.println((n?+?1)?+?"The score is "?+?avg3);

if?(avg3?>?(avg2?*?1.2))?{< /p>

System.out.println((n?+?1)?+?"This student won the first-class general");

}

if?( avg3?>?(avg2?*?1.1))?{

System.out.println((n?+?1)?+?"This student won the 2nd level general");

} } }

}

That’s it

ArrayList is a dynamic array