Question

In Java Programming Complete the Code that remains to be implemented follow the guide lines here...

In Java Programming Complete the Code that remains to be implemented follow the guide lines here and finish what code remains name of program class Student.java

package course;

public class Student {

    private String firstName;
    private String lastName;
    private Address homeAddress;
    private Address schoolAddress;
    private double[] testScores;

        // Four parameter constructor
    public Student(String firstName, String lastName, Address homeAddress, Address schoolAddress) {
        // Call the seven parameter constructor. Pass zeros for the three grades
    }

        // Five parameter constructor
    public Student(String firstName, String lastName, Address homeAddress, Address schoolAddress, double[] testScores) {
        // Call the seven parameter constructor. Pass a testScores element to each grade
    }

        // Seven paramter constructor
    public Student(String firstName, String lastName, Address homeAddress, Address schoolAddress, double testScore1, double testScore2, double testScore3) {
        // Assign each of the first four parameters to the appropriate instance variable
                                
                // Instantiate a three element array of doubles for testScores
                
                // Assign the last three parameters to the appropriate testScores element

    }

        // Sets the value of testScores with testNumber - 1 to score
    public void setTestScore(int testNumber, double score) {

    }

        // Gets the value of testScores with testNumber - 1
    public double getTestScore(int testNumber) {

    }

        // Returns the average of the three test scores
    public double average() {

    }

    @Override
    public String toString()
    {
        String result;

        result = firstName + " " + lastName + "\n";
        result += "Home Address:\n" + homeAddress + "\n";
        result += "School Address:\n" + schoolAddress + "\n";
        result += "Test Scores: ";
        for (int i = 0; i < testScores.length - 1; i++) {
            result += testScores[i] + ", ";
        }
        result += testScores[testScores.length - 1] + "\n";
        result += "Average: " + average();

        return result;
    }
}

This is another class of the code called Address.java its to be ran with the following code above

package course;

public class Address {

    private String streetAddress;
    private String city;
    private String state;
    private long zipCode;

    public Address(String streetAddress, String city, String state, long zipCode) {
        this.streetAddress = streetAddress;
        this.city = city;
        this.state = state;
        this.zipCode = zipCode;
    }

    @Override
    public String toString() {
        String result;

        result = streetAddress + "\n";
        result += city + ", " + state + " " + zipCode;

        return result;
    }
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Address.java

public class Address {
private String streetAddress;
private String city;
private String state;
private long zipCode;
  
public Address(String streetAddress, String city, String state, long zipCode)
{
this.streetAddress = streetAddress;
this.city = city;
this.state = state;
this.zipCode = zipCode;
}

@Override
public String toString()
{
String result;

result = streetAddress + "\n";
result += city + ", " + state + " " + zipCode;

return result;
}
}

Student.java

public class Student {
private String firstName;
private String lastName;
private Address homeAddress;
private Address schoolAddress;
private double[] testScores;
  
// Four parameter constructor
public Student(String firstName, String lastName, Address homeAddress, Address schoolAddress)
{
this(firstName, lastName, homeAddress, schoolAddress, 0, 0, 0);
}
  
// Five parameter constructor
public Student(String firstName, String lastName, Address homeAddress, Address schoolAddress, double[] testScores)
{
this(firstName, lastName, homeAddress, schoolAddress, testScores[0], testScores[1], testScores[2]);
}
  
// Seven paramter constructor
public Student(String firstName, String lastName, Address homeAddress,
Address schoolAddress, double testScore1, double testScore2, double testScore3)
{
this.firstName = firstName;
this.lastName = lastName;
this.homeAddress = homeAddress;
this.schoolAddress = schoolAddress;
  
this.testScores = new double[3];
this.testScores[0] = testScore1;
this.testScores[1] = testScore2;
this.testScores[2] = testScore3;
}
  
// Sets the value of testScores with testNumber - 1 to score
public void setTestScore(int testNumber, double score)
{
this.testScores[testNumber - 1] = score;
}

// Gets the value of testScores with testNumber - 1
public double getTestScore(int testNumber)
{
return this.testScores[testNumber - 1];
}

// Returns the average of the three test scores
public double average()
{
double total = 0.0;
for(int i = 0; i < 3; i++)
{
total += this.testScores[i];
}
return(total / 3.00);
}

@Override
public String toString()
{
String result;

result = firstName + " " + lastName + "\n";
result += "Home Address:\n" + homeAddress + "\n";
result += "School Address:\n" + schoolAddress + "\n";
result += "Test Scores: ";
for (int i = 0; i < testScores.length - 1; i++) {
result += testScores[i] + ", ";
}
result += testScores[testScores.length - 1] + "\n";
result += "Average: " + average();

return result;
}
}

Tester.java

public class Tester {
  
public static void main(String[] args)
{
Address homeAddress = new Address("7554", "Depew", "New York", 14043);
Address schoolAddress = new Address("7189", "Parsippany", "New Jersey", 07054);
double testScores[] = new double[3];
testScores[0] = 56.50;
testScores[1] = 78;
testScores[2] = 88.50;
  
Student student = new Student("John", "Doe", homeAddress, schoolAddress, testScores);
  
System.out.println(student.toString());
}
}

******************************************************************* SCREENSHOT ********************************************************

Add a comment
Know the answer?
Add Answer to:
In Java Programming Complete the Code that remains to be implemented follow the guide lines here...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a class called Course_xxx that represents a course taken at a school. Represent each student...

    Write a class called Course_xxx that represents a course taken at a school. Represent each student using the Student class from the Chapter 7 source files, Student.java. Use an ArrayList in the Course to store the students taking that course. The constructor of the Course class should accept only the name of the course. Provide a method called addStudent that accepts one Student parameter. Provide a method called roll that prints all students in the course. Create a driver class...

  • What is wrong with this Code? Fix the code errors to run correctly without error. There...

    What is wrong with this Code? Fix the code errors to run correctly without error. There are four parts for one code, all are small code segments for one question. public class StudentTest { public static void main(String[] args){ // Part Time Student Test Student ft1 = new PartTimeStudent("George", "Bush", "123-12-5678", 1, 2 ); System.out.println(ft1); Student ft2 = new PartTimeStudent("Abraham", "Lincoln", "001-90-5323", 6, 22 ); System.out.println(ft2); // Full Time Student Test Student pt1 = new FullTimeStudent("Nikola", "Tesla", "442-00-0998", 8, 26...

  • Here is the code from the previous three steps: #include <iostream> using namespace std; class Student...

    Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...

  • Requirements:  Your Java class names must follow the names specified above. Note that they are...

    Requirements:  Your Java class names must follow the names specified above. Note that they are case sensitive. See our template below.  BankAccount: an abstract class.  SavingAccount: a concrete class that extends BankAccount. o The constructor takes client's firstname, lastname and social security number. o The constructor should generate a random 6-digit number as the user account number. o The initial balance is 0 and the annual interest rate is fixed at 1.0% (0.01).o The withdraw method signature...

  • FOR JAVA: Summary: Create a program that adds students to the class list (see below). The...

    FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...

  • JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you...

    JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you created in the previous lab. In this lab, create a Student class with the following class variable: Student name: Name (Note: Name is a datatype) Student Id: String Create the getter and setter methods. In addition to these methods, create a toString() method, which overrides the object class toString() method. This override method prints the current value of any of this class object. Complete...

  • Language Java Step 1: Design a class called Student. The Student class should contain the following...

    Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...

  • I need help with adding comments to my code and I need a uml diagram for...

    I need help with adding comments to my code and I need a uml diagram for it. PLs help.... Zipcodeproject.java package zipcodesproject; import java.util.Scanner; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Zipcodesproject { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); BufferedReader reader; int code; String state,town; ziplist listOFCodes=new ziplist(); try { reader = new BufferedReader(new FileReader("C:UsersJayDesktopzipcodes.txt")); String line = reader.readLine(); while (line != null) { code=Integer.parseInt(line); line =...

  • The following is for java programming. the classes money date and array list are so I are are pre...

    The following is for java programming. the classes money date and array list are so I are are pre made to help with the coding so you can resuse them where applicable Question 3. (10 marks) Here are three incomplete Java classes that model students, staff, and faculty members at a university class Student [ private String lastName; private String firstName; private Address address; private String degreeProgram; private IDNumber studentNumber; // Constructors and methods omitted. class Staff private String lastName;...

  • For this problem, we are going to revisit the Online Company exercise from lesson 3. In...

    For this problem, we are going to revisit the Online Company exercise from lesson 3. In lesson 3, we created 3 classes, a superclass Company, a subclass OnlineCompany and a runner class CompanyTester. You can take your solutions from lesson 3 for the Company and OnlineCompany, but we are going to redesign the CompanyTester in this exercise. Your task is to create a loop that will allow users to enter companies that will then get stored in an ArrayList. You...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT