// Aaron Amankwaah
// 09/23/2020
// HW1-V2 #4
// Implement a class Student. A student has a name and a total quiz score. Supply an appropriate
// constructor, and methods getName(), addQuiz(int score), getTotalScore(), and
// getAverageScore(). To compute the latter, also need to store the number of quizzes that the
// student took.
import java.util.ArrayList;
import java.util.*;
public class Student{
public static void main
(String[] args
){
System.
out.
println("This is Homeowrk 1 - Question #4. By Aaron Amankwaah, Output Below! \n");
// ArrayList<Student> students = new ArrayList<Student> ();
Student jerry = new Student("Jerry",0.0);
add(jerry);
jerry.addQuiz(86);
jerry.getTotalScore();
jerry.getAverageScore();
// students.get(0).addQuiz(86);
// students.get(0).getTotalScore();
// students.get(0).getAverageScore();
System.
out.
printf("Quizzes total score : %1.0f\n", jerry.
getTotalScore());
System.
out.
println("\n Avverage Quiz Score: " + jerry.
getAverageScore());
}
public static class Student{
private ArrayList<Double> quizzes = new ArrayList<Double> ();
private String name
; double quizTotal
;
private ArrayList<Student> students = new ArrayList<Student> ();
//constructor
public static Student
(String name,
double quizTotal
){
name = name;
quizTotal = quizTotal;
}
public static addStudent(Student identifier) {
students.add(identifier);
}
//Add item to cash register
public static void addQuiz(int score){
quizzes.add(score);
quizTotal += score;
}
//Get total price for current sale
public static int getTotalScore(){
return quizTotal;
}
public static double getAverageScore(){
return quizTotal/quizzes.size();
}
public static String getName
(){
return name;
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}