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'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 class:
o A constructor __init__ that, given an id, and a name, creates a
Student
with those values and zero course-credits and zero course
load.
o A __str__ which prints out students ID, Last name, credits and
course
load.
o A registerCurrent(X) method that add X credits to the course
load. The
course load need to be must be positive and no greater than 18
credits,
otherwise no change happens.
o A withdraw(X) method, which decreases the course load by X
credits.
X has to be positive and courseload cannot be below 0.
o A passedCourse(X) method, which removes X credits from the
current
courseload and adds to the students credits variables. X cannot
be
negative, and cannot be less than the courseload.
o A createEmail() method, which print a string. The string should
be an
email address of the student's name combined with their ID
and
remainder of @rutgers.edu. For example, a student with last
name
"Soni", and ID 25 should return
"[email protected]"
Please show all of the 6 parts successfully running in order to
earn your points. You
may need to demonstrate repeatedly so show all functionality.
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
#code
class Student:
#constructor taking id and name
def
__init__(self,id,name):
self.__id=id
self.__name=name
self.__credits=0
self.__courseLoad=0
#returns string containing id, name, credits
and course load
def __str__(self):
return
'ID: '+str(self.__id)+', Name:
'+self.__name+', Credits:
'+str(self.__credits)+\
', Course Load: '+str(self.__courseLoad)
#adds X to __courseLoad
def
registerCurrent(self,X):
#X must be positive
and X+__courseLoad <=18
if
X>0 and (X+self.__courseLoad)<=18:
self.__courseLoad+=X
#subtracts X from __courseLoad
def withdraw(self,
X):
#X must be positive
and __courseLoad-X should not go negative
if
X>0 and X<=self.__courseLoad:
self.__courseLoad-=X
#subtracts X from __courseLoad and adds to
__credit
def passedCourse(self,
X):
if X
> 0 and X <= self.__courseLoad:
self.__courseLoad-=X
self.__credits+=X
#creates and returns the email id
def
createEmail(self):
return
self.__name+str(self.__id)+'@rutgers.edu'
#main method for testing
def main():
#creating a Student with ID 123 and name
Oliver
s=Student(123,'Oliver')
#printing student details using
__str__()
print('Actual: ',s)
#printing expected values
print('Expected: ID: 123, Name:
Oliver, Credits: 0, Credit Load: 0')
print() #line break
#adding 4 to current course load, displaying
actual and expected values
s.registerCurrent(4)
print('Actual: ', s)
print('Expected: ID: 123, Name: Oliver,
Credits: 0, Credit Load: 4')
print()
# adding -3 to current course load, should
make no changes
s.registerCurrent(-3)
print('Actual: ', s)
print('Expected: ID: 123, Name: Oliver,
Credits: 0, Credit Load: 4')
print()
# adding 100 to current course load, should
make no changes
s.registerCurrent(100)
print('Actual: ', s)
print('Expected: ID: 123, Name: Oliver,
Credits: 0, Credit Load: 4')
print()
# withdrawing 1 from course load, should
change
s.withdraw(1)
print('Actual: ', s)
print('Expected: ID: 123, Name: Oliver,
Credits: 0, Credit Load: 3')
print()
# withdrawing 2 from course load and add 2
to credits, should change
s.passedCourse(2)
print('Actual: ', s)
print('Expected: ID: 123, Name: Oliver,
Credits: 2, Credit Load: 1')
print()
#displaying actual and expected email id
created
print('Actual: ',
s.createEmail())
print('Expected:
[email protected]')
#running main()
main()
#output
Actual: ID: 123, Name: Oliver, Credits: 0, Course Load: 0
Expected: ID: 123, Name: Oliver, Credits: 0, Credit Load: 0
Actual: ID: 123, Name: Oliver, Credits: 0, Course Load: 4
Expected: ID: 123, Name: Oliver, Credits: 0, Credit Load: 4
Actual: ID: 123, Name: Oliver, Credits: 0, Course Load: 4
Expected: ID: 123, Name: Oliver, Credits: 0, Credit Load: 4
Actual: ID: 123, Name: Oliver, Credits: 0, Course Load: 4
Expected: ID: 123, Name: Oliver, Credits: 0, Credit Load: 4
Actual: ID: 123, Name: Oliver, Credits: 0, Course Load: 3
Expected: ID: 123, Name: Oliver, Credits: 0, Credit Load: 3
Actual: ID: 123, Name: Oliver, Credits: 2, Course Load: 1
Expected: ID: 123, Name: Oliver, Credits: 2, Credit Load: 1
Actual: [email protected]
Expected: [email protected]
please help me with this python code thank you 1. Write a Student class that stores...
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...
I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student { private String name; private double gpa; private int idNumber; public Student() { this.name = ""; this.gpa = 0; this.idNumber = 0; } public Student(String name, double gpa, int idNumber) { this.name = name; this.gpa = gpa; this.idNumber = idNumber; } public Student(Student s)...
Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....
Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course { /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...
Given a class called Student and a class called Course that contains an ArrayList of Student. Write a method called getDeansList() as described below. Refer to Student.java below to learn what methods are available. I will paste both of the simple .JAVA codes below COURSE.JAVA import java.util.*; import java.io.*; /****************************************************** * A list of students in a course *****************************************************/ public class Course{ /** collection of Students */ private ArrayList<Student> roster; /***************************************************** Constructor for objects of class Course *****************************************************/...
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...
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...
Must be in Python 3 exercise_2.py # Define the Student class class Student(): # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...
Student class: Instance variables name id Constructors: Default constructor Constructor that has id and name passed to the constructor Methods: Accessors int getID( ) String getName( ) Class Roster: This class will implement the functionality of all roster for school. Instance Variables a final int MAX_NUM representing the maximum number of students allowed on the roster an ArrayList storing students Constructors a default constructor should initialize the list to empty strings a single parameter constructor that takes an ArrayList<Student> Both...
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...