Question: /* * * NOTE: This program does not produce any valid output. * * HINT: There is something wrong with the constructor * and the

/* * * NOTE: This program does not produce any valid output. * * HINT: There is something wrong with the constructor * and the toString( ) method below. */ public class FullTimeStudent extends Student {

private final String STATUS = "Full Time";

public FullTimeStudent(String firstName, String lastName, String ssn, int numberOfCourses, int numberOfCredits) { }

@Override public String ToString(){ return String.format(" %s Status: %s Amount Due: $%.2f", super.toString(), STATUS, super.calculateCostForSemester()); } }

-------------------------------------------------------------------------------------------------------------------------------------------

/* * NOTE: This program does not produce any valid output. * * HINT: . The issue with this file is inheritance. Also, * just because you are getting errors (red stop signs to the left * side) may not mean the error is located at those locations. This * file should also inherit from Student. */ public class PartTimeStudent {

private final String STATUS = "Part Time";

public PartTimeStudent(String firstName, String lastName, String ssn, int numberOfCourses, int numberOfCredits) {

super(firstName, lastName, ssn, numberOfCourses, numberOfCredits ); }

@Override public double calculateCostForSemester(){

return super.calculateCostForSemester() * .9; }

@Override public String toString(){ return String.format(" %s Status: %s Amount Due: $%.2f", super.toString(), STATUS, calculateCostForSemester()); } }

-----------------------------------------------------------------------

/* Run this class to test FullTimeStudent and PartTimeStudent; you must debug those classes before you can execute this test class.

Output format should be:

Name: George Bush SSN: 123-12-5678 Course Count: 1 Credit Hours: 2 Status: Part Time Amount Due: $151.20

Name: Abraham Lincoln SSN: 001-90-5323 Course Count: 6 Credit Hours: 22 Status: Part Time Amount Due: $1663.20

Name: Nikola Tesla SSN: 442-00-0998 Course Count: 8 Credit Hours: 26 Status: Full Time Amount Due: $2184.00

Name: Albert Einstein SSN: 675-78-2311 Course Count: 10 Credit Hours: 32 Status: Full Time Amount Due: $2688.00

*/

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 ); System.out.println(pt1);

Student pt2 = new FullTimeStudent("Albert", "Einstein", "675-78-2311", 10, 32 ); System.out.println(pt2); } }

----------------------------------

public class Student { private String firstName; private String lastName; private String ssn; private int numberOfCourses; private int numberOfCredits; private final double HOURLY_RATE = 84.0;

public Student(String firstName, String lastName, String ssn, int numberOfCourses, int numberOfCredits) { this.firstName = firstName; this.lastName = lastName; this.ssn = ssn; this.numberOfCourses = numberOfCourses; this.numberOfCredits = numberOfCredits; }

public String getFirstName() { return firstName; }

public void setFirstName(String firstName) { this.firstName = firstName; }

public String getLastName() { return lastName; }

public void setLastName(String lastName) { this.lastName = lastName; }

public int getNumberOfCourses() { return numberOfCourses; }

public void setNumberOfCourses(int numberOfCourses) { this.numberOfCourses = numberOfCourses; }

public int getNumberOfCredits() { return numberOfCredits; }

public void setNumberOfCredits(int numberOfCredits) { this.numberOfCredits = numberOfCredits; }

public String getSSN() { return ssn; }

public void setSSN(String ssn) { this.ssn = ssn; }

public double calculateCostForSemester(){ return (HOURLY_RATE * numberOfCredits); }

public String toString(){ return String.format( " Name: %s %s SSN: %s Course Count: %d Credit Hours: %d", getFirstName(), getLastName(), getSSN(), getNumberOfCourses(), getNumberOfCredits()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!