Question

Write a Student class that stores information for a Montclair student. The class should include the...

Write a Student class that stores information for a Montclair student. The class should include the following instance variables

    • id, an integer identifier for the student
    • lastName, a string for the student's last name
    • creditsEarned, an integer representing the number of course-credits the student has earned
    • courseLoadCredits, an integer representing the current number of credits in progress.
    • status, an integer representing the status of the student (1 means freshman, 2 means sophomore, 3 means junior, 4 means senior). This status NEEDs to be updated automatically based on creditsEarned. That is, If your creditsEarned is below 30 credits, you are freshman, between 30 but below 60, you are sophomore. between 60 but below 90, you are junior. Between 90 to 120 you are senior.

Write the following methods for your Student class:

    • A constructor (__init__) that, given an id, and a name, creates a Student with those values and no course-credits and no course load.
    • A registerCourse method that add to the current course load with an input parameter for the credit (for example, three credit will be 3). The credit load must be positive and courseLoadCredits cannot be greater than 18 credits. Show an error message indicating otherwise.
    • A withdraw method, which decreases the course load by an input parameter (for example, three credit will be 3), but never goes below 0 (need if statement).
    • A passedCourse method, which removes one courses credits (eg.3 credits) from the current course load and adds to the students overall creditsEarned.
    • A createEmail method, which returns a string. The string should be an email address of the student's name combined with their ID and remainder of @Montclair.edu. For example, a student with last name "Jackson", and ID 123 should return "[email protected]"

Create a sub class call Graduate_Student, which inherit from the Student class.

All instances variables should be the same except that the status variable be updated to 5.

Write the following methods for your sub class:

    • A registerCourse method that add to the current course load with an input parameter for the credit (for example, three credit will be 3). The credit load must be positive and courseLoadCredits cannot be greater than 15 credits. Show an error message indicating otherwise.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class Student
{
   int id;
   String lastName;
   int creditsEarned;
   int courseLoadCredits;
   int status;
   public Student(int idd, String name)
   {
       id=idd;
       lastName=name;
   }
   public void registerCourse(int courseLoad)
   {
       if(courseLoad>0 && (courseLoadCredits+courseLoad<19))
       {
           courseLoadCredits+=courseLoad;
       }
       else
       {
           System.out.print("courseLoadCredits cannot be greaterthan 18")
       }
   }
   public void withdraw(int courseLoad)
   {
       if(courseLoadCredits-courseLoad>0)
       {
           courseLoadCredits-=courseLoad;
       }
   }
   public void passedCourse(int val)
   {
       courseLoadCredits-=val;
       creditsEarned+=val;
   }
   public String createEmail()
   {
       String email;
       email=lastName+Integer.toString(id)+"@Montclair.edu";
       return email;
   }
}
public class Graduate_Student extends Student
{
   public void registerCourse(int credit)
   {
       if(credit>0 && courseLoadCredits+credit<16)
           {
               courseLoadCredits+=credit;
           }
           else
           {
               System.out.print("Credit cannot be greaterthan 15")
           }
   }
}

Add a comment
Know the answer?
Add Answer to:
Write a Student class that stores information for a Montclair student. The class should include the...
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
  • please help me with this python code thank you 1. Write a Student class that stores...

    please help me with this python code thank you 1. Write a Student class that stores information for a Rutgers student. The class should include the following instance variables: (10 points) o id, an integer identifier for the student o lastName, a string for the student&#39;s last name o credits, an integer representing the number of course-credits the student has earned o courseLoad, an integer representing the current number of credits in progress Write the following methods for your Student...

  • PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class...

    PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...

  • Last picture is the tester program! In this Assignment, you will create a Student class and...

    Last picture is the tester program! In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...

  • please help Write a simple program with Student class having STL list of Record's structure as...

    please help Write a simple program with Student class having STL list of Record's structure as a member. 1. Records of the Students are not accessible to the outside world. 2. Student shall output its standing (Freshman, Sophomore etc). 3. A Student can only be created with the name 4. A class can only be added if there is a class name and the passing grade. Driver program creates a Student, adds few classes to the Student's records, then prints...

  • Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman...

    Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...

  • Java Programming Design a class named Person and its two subclasses named Student and Employee. A...

    Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....

  • a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person...

    a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...

  • Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee

    In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....

  • This Question: 1 pt 15 A frequency distribution for the class level of students in an...

    This Question: 1 pt 15 A frequency distribution for the class level of students in an introductory statistics course is shown. Two students are randomly selected without replacement. Complete parts (a) Class Frequency Freshman Sophomore16 through (d). Junior Senior a. Determine the probability that the first student obtained is a junior and the second a senior. The probability that the first student obtained is a junior and the second a senior is Type an integer or a decimal rounded to...

  • Consider the following partial UML class diagram for the class Student:

    Consider the following partial UML class diagram for the class Student:Student-studentID: String-name: String-school: String+validateStudentID (s: Student):boolean studentID is a string that consists of a letter representing the school followed by 5 digits. The codes used for the schools in this scenario are shown below:SchoolCodeExample of student IDFASC'A'"A12345" refers to a student from FASC.FAFB'B'"B88888" refers to a student from FAFB.Write the code for the method validateStudentID (Student student) such that it performs validations on the parameter's student ID to ensure that:- the...

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
ADVERTISEMENT