Using Python:
Par 1.
You will define Student class with the following attributes:
In addition, you will do the following tasks:
|
Attribute |
Width |
Alignment |
|
|
1 |
CWID |
12 |
Center |
|
2 |
FirstName |
15 |
Left justified |
|
3 |
LastName |
10 |
Left justified |
|
4 |
ClassID |
9 |
Center |
|
5 |
Grade |
5 |
Right justified |
Part 2.
Implement Python function according to the following requirements:
Thanks for the question, I have done both Part 1 and Part 2. here is the code with screenshot.
Let me know for any questions or doubts.
===================================================================================
class Student():
def __init__(self,cwid,fname,lname,gender,date,id,class_Date,grade):
self.cwid=cwid
self.first_name=fname
self.last_name=lname
self.gender=gender
self.birth_date=date
self.class_id=id
self.class_date=class_Date
self.grade=grade
def set_cwid(self,cwid):
self.cwid=cwid
def set_first_name(self,fname):
self.first_name=fname
def set_last_name(self,lname):
self.last_name=lname
def set_gender(self,gender):
self.gender=gender
def set_birth_date(self,date):
self.birth_date=date
def set_class_id(self,id):
self.class_id=id
def set_class_date(self,date):
self.class_date=date
def set_grade(self,grade):
self.grade=grade
def get_cwid(self):
return self.cwid
def get_first_name(self):
return self.first_name
def get_last_name(self):
return self.last_name
def get_gender(self):
return self.gender
def get_birth_date(self):
return self.birth_date
def get_class_id(self):
return self.class_id
def get_class_date(self):
return self.class_date
def get_grade(self):
return self.grade
def output(self):
return str.format('{0:^12}{1:<15}{2:<10}{3:^9}{4:>5}',self.cwid,self.first_name,self.last_name,\
self.class_id,self.grade)
# Part 1
student=Student(3472634,'John','Peter','M','03/14/1999',123,'03/14/2015',3.7)
print(student.output())
# Part 2
def main():
# read data from file
file_name='D:\\students.txt'
students_list=[]
with open(file_name,'r')as read_file:
# read each line
for line in read_file.readlines():
# split the line by comma
line = line.strip().split(',')
# create object of student
s=Student(int(line[0]),line[1],line[2],line[3],line[4],line[5],line[6],float(line[7]))
# aadd the object to the student list
students_list.append(s)
# iterate over the list and print each object
for student in students_list:
print(student.output())
main()
===================================================================================

Using Python: Par 1. You will define Student class with the following attributes: CWID: the student’s...
A) Please implement a Python script to define a student class with the following attributes (instance attributes): cwid: student’s CWID first_name : student’s first name last_name: student’s last name gender: student’s gender gpa: student’s gpa Please make these attributes as private ones so they have to be accessed via getter/setter methods or property. For this purpose, please define a getter/setter method and property for each of the attributes. Another thing you need to do is to define a constructor that...
We will build one Python application via which users can perform various analytics tasks on data in 2-D table (similar to Spreadsheet) format which looks like: Column Name 1 Column Name 2 Column Name 3 Column Name N … … … … … In this table, each row represents the data of one object that we are interested in. Columns, on the other hand, represent the attributes of these objects. For example, this table could represent students’ academic records. Each...
public class StudentADT { //1. A Student class should include data attributes including a // student’s name (first, and last), a student number, //an array of 3 assignment grades, and an exam grade. private String firstName; private String lastName; private int studentNumber; private double[] assignmentGrades; private double examGrade; //the constructor StudentADT(firstNm, lastNm, stNo, asn1Grade, asn2Grade, asn3Grade, examGrade) public StudentADT(String firstNm, String lastNm, int stNo, double asn1Grade, double asn2Grade, double asn3Grade, double examGrade) { firstName = firstNm; lastName = lastNm; studentNumber...
1. Do the following a. Write a class Student that has the following attributes: - name: String, the student's name ("Last, First" format) - enrollment date (a Date object) The Student class provides a constructor that saves the student's name and enrollment date. Student(String name, Date whenEnrolled) The Student class provides accessors for the name and enrollment date. Make sure the class is immutable. Be careful with that Date field -- remember what to do when sharing mutable instance variables...
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...
You are given a file consisting of students’ names in the following form: lastName, firstName middleName. (Note that a student may not have a middle name.) Write a C++ program that converts each name to the following form: firstName middleName lastName. Your program must read each student’s entire name in a variable and must consist of a function that takes as input a string, consists of a student’s name, and returns the string consisting of the altered name. Use the...
( Object array + input) Write a Java program to meet the following requirements: 1. Define a class called Student which contains: 1.1 data fields: a. An integer data field contains student id b. Two String data fields named firstname and lastname c. A String data field contains student’s email address 1.2 methods: a. A no-arg constructor that will create a default student object. b. A constructor that creates a student with the specified student id, firstname, lastname and email_address...
Java - In NetBeans IDE: • Create a class called Student which stores: - the name of the student - the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into...
Introduction In this lab, you will be working with three classes: Person, Student, and Roster. Person and Student represent individuals with a first and last name as String class variables, and Student has an additional int class variable that represents a ID number. The Roster class represents a group of people that are objects of either the Person or Student class. It contains an ArrayList. The Person class has been completed for you with class variables, a constructor, and a...