7*****Help with JAVA, noob when it comes to this, please explain and show OUTPUT
ID: 3825404 • Letter: 7
Question
7*****Help with JAVA, noob when it comes to this, please explain and show OUTPUT PLEASE!!********
Implement aclass Student. For the purpose of this exercise, 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, you also need to store the number of quizzes that student took.
1. Use the Lab7StudentTester class (Lab7StudentTester.java) to test your Student class. The StudentTester class produces the following output:
2.After completing part 1, add the following instance methods to the Student class.
a. getHighestScore – returns the highest quiz score. Returns Integer.MIN_VALUE if there are no quiz scores.
b. getLowestScore – returns the lowest quiz score. Returns Integer.MAX_VALUE if there are no quiz scores
c. getScores – returns an int array (int[]) that contains the quiz scores is ascending order. The array length is the number of quiz scores. Returns a zero length int array if there are no quiz scores.
d. toString – returns a string that contains the student name, the number of quizzes, and each quiz score.
3. After completing part 2, modify the Lab7StudentTester class to test the new Student class methods.
HERE'S the Code:
run Test 1 Inputs name "Jane" quizzes [80, 90, 85, 100 Outputs name Jane quiz total 355 quiz avg 88 Test 2 Inputs name Bil quizzes [75 93 88, 84, 91, 80, 78] Outputs name Bi quiz total 589 quiz avg 84 BUILD SUCCESSFUL (total time 0 secondsExplanation / Answer
package student;
import java.util.*;
public class StudentList {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int size;
System.out.println(" Enter the maximum number of student:");
size = sc.nextInt();
int i = 0;
boolean flag = false;
Student list[] = new Student[size];
char choice;
while (!flag) {
System.out
.println(" ******* ");
System.out.println("1. Admission");
System.out.println("2. Enter marks");
System.out.println("3. Display marksheet");
System.out.println("4. Total number of students");
System.out.println("6. EXIT");
System.out.println("Enter choice: ");
choice = sc.next().charAt(0);
switch (choice) {
case '1':
if (i >= size) {
System.out.println("Maximum student capacity reached");
break;
}
list[i] = new Student();
list[i].admission();
list[i].get_marks();
i++;
break;
case '2': {
int j, k;
System.out
.println("Enter the student roll number whose marksheet is to be prepared: ");
k = sc.nextInt();
for (j = 0; j < Student.student_count; j++) {
if (list[j].ret_roll() == k) {
list[j].get_marks();
break;
}
}
if (j == Student.student_count)
System.out.println("Student not admitted yet ");
break;
}
case '3': {
int j, k;
System.out
.println("Enter the student roll number whose marksheet is to be displayed: ");
k = sc.nextInt();
for (j = 0; j < Student.student_count; j++) {
if (list[j].ret_roll() == k) {
list[j].marksheet();
break;
}
}
if (j == Student.student_count)
System.out.println("Student not admitted yet ");
break;
}
case '4':
System.out.println("Total students: ");
Student.student_number();
break;
case '6':
System.out.println("Thank You");
flag = true;
break;
default:
System.out.println(" Invalid choice");
}
}
sc.close();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.