Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Description: A student object consists of: FirstName: string LastName: string Birthdate: tuple, such as (1,17,1998) TechID: string Grades: list of tuples, such as [(3127,C,4),(2496,B,3),(6703,D,3)]

Assignment Description:

A student object consists of:

FirstName: string

LastName: string

Birthdate: tuple, such as (1,17,1998)

TechID: string

Grades: list of tuples, such as [(3127,C,4),(2496,B,3),(6703,D,3)]

So one student might look like this:

FirstName: Bob

LastName: Smith

Birthdate: (2,17,1998)

TechID: 43546578

Grades: [(5930,B,4),(7660,C,4),(3122,C,3),(5438,C,2),

(6730,C,4),(4268,C,4),(5709,D,4),(8071,B,4)]

The data for each student can be found in the text files. Your program should read the data from each of the files, as appropriate. (Do not change the format of the input files.) Your getData function should read in *all* of the data, at one time. And once all of the data has been read into an appropriate structure, that data should be passed back to the main program. Your program should not go back-and-forth between reading data and returning data.

Create a list of students. Do not process the students one-by-one as they are created or as they are placed in the list. Create a student, add it to the list of student objects, repeat. Once the list of students is complete, go through the list to output the report on each student.

You will need three methods for processing a student object.

currentAge: How old is the student? Be sure to use the Python module.

Hint:

import datetime

now = datetime.datetime.now()

print (now.year)

currentGPA: What is the students GPA?

Report: Add the output for that student to the output file.

Each output file item should look like this, using the above student as an example:

Bob Smith (#43546578)

Age: 18 (02/17/1998) note the mm/dd/yyyy format

GPA: 2.14 (29 credits)

There will be at least three Python files being used one for getData, one with the student class and its methods, and one with the main program. Please use python as the programming language for this assignment. There need to be three programs, two of them need getData.py and the student class , to be implemented in the main.py program. also the two text files (students. txt and grades.txt) where you can obtain the data from is given in the link: https://drive.google.com/file/d/1a24cGWnfJG3zhjDos4rcAqNIQT58HOdE/view?usp=sharing.

To obtain GPA formula use this resource:https://www.weber.edu/ssc/gpabyhand.html. use the format for standard grades A,B,C,D & F with respective values 4.0, 3.0, 2.0, 1.0 & 0.0 is an F. And then take the credit values for each class, total them all up (points that student has achieved) and then divide them by the total number of points that the student has received. and you get the students cumulative GPA for the semester.

For eg. Bob got [(5930,B,4),(7660,C,4),(3122,C,3),(5438,C,2),

(6730,C,4),(4268,C,4),(5709,D,4),(8071,B,4)]

which means that he got has taken 4, 4, 3, 2,4, 4, 4,4 as the credit hours. The grade is the credits that he recieved B-3, C-2,C-2,C2, C-2,C-2, D-1, B-3 which makes it 3+2+2+2+2+2+1+3 = 17. Now divide 17/(4+4+3+2+4+4+4+4) = 58.6% which is an F since 4.0 is a 100%. I hope this makes some sense.

Essentially the main program should implement the other two programs in it and read the data from the students.txt in order to figure out the corresponding techID for each student. Then that should ID be crossreferenced with the grades.txt in order to figure out the students final grade and GPA. Once again thanks a lot for helping. Please add comments if possible. I am using PyCharm IDE for compatibility standard. Can you please ensure that the program works on PyCharm. The code below I have received from another question I was wondering if it could be modified to suit these requirements. I am having a hard time fixing the code and none of the responses provided adress these issues.

Can someone fix this code so that it:-

1) runs well

2) it uses the student class and the getData.py as a seperate file that is inputed into the main.py.

3) check thee provided program for any compliation errors. Use the link in the decription for the students.txt and grades.txt file as file one and file two being inputed.

4) to calculate GPA refer to the link :For eg. Bob got [(5930,B,4),(7660,C,4),(3122,C,3),(5438,C,2), (6730,C,4),(4268,C,4),(5709,D,4),(8071,B,4)] which means that he got has taken 4, 4, 3, 2,4, 4, 4,4 as the credit hours. The grade is the credits that he recieved B-3, C-2,C-2,C2, C-2,C-2, D-1, B-3 which makes it 3+2+2+2+2+2+1+3 = 17. Now divide 17/(4+4+3+2+4+4+4+4) = 58.6% which is an F since 4.0 is a 100%. http://gpacalculator.net/how-to-calculate-gpa/semester-gpa/

#!/usr/bin/python import os.path from datetime import date

studentList = []; gradesList = []; outputFileName = "output.txt"; inputFileOneName = "inputOne.txt"; inputFileTwoName = "inputTwo.txt";

class Student:

def __init__(self, firstName, lastName, birthDate, techID, grades): self.firstName = firstName; self.lastName = lastName; self.birthDate = birthDate; self.techID = techID; self.grades = grades;

def currentAge(self): birthDay = self.birthDate[0] birthMonth = self.birthDate[1] birthYear = self.birthDate[2] today = date.today() return today.year - birthYear - ((today.month, today.day) < (birthMonth, birthDay))

def currentGPA(self): # I don't know how to calculte GPA from grages # Give the formula, I will update the code accordingly totalCredits = 0; for record in self.grades: totalCredits = totalCredits + record[2]; return "2.5 (" + str(totalCredits) + " credits)";

def report(self): name = self.firstName + " " + self.lastName + "(#"+ str(self.techID) +")"; doB = str(self.birthDate[0]) +"/" + str(self.birthDate[1]) + "/" + str(self.birthDate[2]); age = "Age : " + str(self.currentAge()) + " (" + doB +")"; gpa = "GPA : " + str(self.currentGPA()); return (" " + name + " " + age +" " +gpa +" ");

def readFromFileOne(fileName): doesFileExists = False; if os.path.isfile(fileName) : doesFileExists = True;

# If the file exists then Load the existing data into the studentList if doesFileExists : fileInstance = open(fileName,'r'); fileText = fileInstance.read(); lineSplits = fileText.split(" "); for line in lineSplits : if line == "" : continue; wordSplits = line.split(",") techID = int(wordSplits[0]); firstName = wordSplits[1]; lastName = wordSplits[2]; doBString = wordSplits[3];

dobSplits = doBString.split("/"); dobTuple = (int(dobSplits[0]), int(dobSplits[1]), int(dobSplits[2]));

studentGrades = [] for record in gradesList: if record[0] == techID: studentGrades.append((record[1], record[2], record[3]));

student = Student(firstName, lastName, dobTuple, techID, studentGrades); studentList.append(student);

def readFromFileTwo(fileName): doesFileExists = False; if os.path.isfile(fileName) : doesFileExists = True;

# If the file exists then Load the existing data into the studentList if doesFileExists : fileInstance = open(fileName,'r'); fileText = fileInstance.read(); lineSplits = fileText.split(" "); for line in lineSplits : if line == "" : continue; wordSplits = line.split(",") techID = int(wordSplits[0]); classID = int(wordSplits[1]); grade = wordSplits[2]; credits = int(wordSplits[3]); gradesList.append((techID, classID, grade, credits));

def readFromFile(): readFromFileTwo(inputFileTwoName); readFromFileOne(inputFileOneName);

# Starting the procedure readFromFile(); fileInstance = open(outputFileName,'w'); for student in studentList: ouputString = student.report(); fileInstance.write(ouputString); fileInstance.close();

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

Explain the various techniques of Management Development.

Answered: 1 week ago

Question

2. Outline the functions of nonverbal communication

Answered: 1 week ago