Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

REFER TO THE FOLLOWING CODE FOR THE TASK BELOW: public class Student { private String name; private int test1; private int test2; private int test3;

REFER TO THE FOLLOWING CODE FOR THE TASK BELOW: public class Student { private String name; private int test1; private int test2; private int test3; public Student() { name =""; test1 = 0; test2 = 0; test3 = 0; } public Student(String nm, int t1, int t2, int t3){ name = nm; test1 = t1; test2 = t2; test3 = t3; } public Student(Student s){ name = s.name; test1 = s.test1; test2 = s.test2; test3 = s.test3; } //set a student's name public void setName(String nm) { name = nm; } //get a student's name public String getName() { return name; } //post: set test i to score public void setScore(int i, int score) { if(i == 1) test1 = score; if(i == 2) test2 = score; else test3 = score; } //post: return score i public int getScore(int i) { if(i == 1) return test1; else if(i == 2) return test2; else return test3; } //post: compute and return average public int getAverage() { int average; average = (int) Math.round((test1+test2+test3)/3.0); return average; } //post: determien and return highest score public int getHighScore() { int highScore; highScore = test1; if(test2>highScore)highScore = test2; if(test3>highScore)highScore = test3; return highScore; } //post: construct and return string representation of the student public String toString() { String str; str = "Name: " + name + " " + "Test 1: " + test1 + " " + "Test 2: " + test2 + " " + "Test 3: " + test3 + " " + "Average: " + getAverage(); return str; } }

THE TASK IS THAT IS TO BE DONE USING JAVA ON REPL.IT IS:

Create a driver that instantiates two Students. Create the first Student using the 4-argument custom constructor, and the second Student using the 1-argument custom constructor. Use the .toString() method to verify that both Students output the same details.

Can someone please help create the code with basic, beginner java? I'm a little lost here.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

a. What is the purpose of the team?

Answered: 1 week ago

Question

b. What are its goals and objectives?

Answered: 1 week ago