d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > C++ Assignment
Add Reply New Topic New Poll
Member
Posts: 4,332
Joined: Mar 31 2011
Gold: 71.00
Nov 25 2012 11:56pm
Forum Gold To Whoever Does This For Me

The mid-semester point at your local university is approaching. The registrar's office wants to prepare grade reports as soon as the students' grades are recorded. However, some of the students enrolled have not yet paid their tuition.

1. If a student has paid the tuition, the grades are shown on the grade report together with the grade-point average (GPA).
2. If a student has not paid the tuition, the grades are not printed. For these students, the grade report contains a message indicating that the grades have been held for nonpayment of the tuition. The grade report also shows the billing amount.

The registrar's office and the business office want you to write a program that can analyze the students' data and print the appropriate grade reports. The data is stored in a file in the following form:
NumStudents TuitionRate
StudentName StudentID IsTuitionPaid NumCourses
CourseName CourseNumber CreditHours Grade
CourseName CourseNumber CreditHours Grade
CourseName CourseNumber CreditHours Grade
.
.
.
StudentName StudentID IsTuitionPaid NumCourses
CourseName CourseNumber CreditHours Grade
CourseName CourseNumber CreditHours Grade
CourseName CourseNumber CreditHours Grade
.
.
.
StudentName StudentID IsTuitionPaid NumCourses
CourseName CourseNumber CreditHours Grade
CourseName CourseNumber CreditHours Grade
CourseName CourseNumber CreditHours Grade
.
.
.

The first line indicates the number of students enrolled and the tuition rate per credit hour. The students' data is given thereafter.

A sample input file is as follows:
3 563
Bob Miller D99008765 Y 4
Mathematics MTH345 4 A
Physics PHY357 3 B
ComputerSci CSC478 3 B
History HIS356 3 A
Bill Nye D88776600 N 2
Mathematics MTH345 4 C
History HIS356 3 D
Samuel Sue D33889922 Y 3
Physics PHY357 3 C
ComputerSci CSC478 3 A
History HIS356 3 C

The first line indicates that the input file contains three students' data and the tuition rate is $563 per credit hours. Next, the students' information and course data for each student is given.

The desired output should look like this (which is written to a file):

Student Name: Bob Miller
Student ID: D99008765
Number of courses enrolled: 4

Course Num Course Name Credits Grade
CSC478 ComputerSci 3 B
HIS356 History 3 A
MTH345 Mathematics 4 A
PHY357 Physics 3 B

Total number of credit hours: 13
Mid-Semester GPA: 3.54
_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*

Student Name: Bill Nye
Student ID: D88776600
Number of courses enrolled: 2

Course Num Course Name Credits Grade
HIS356 History 3 ***
MTH345 Mathematics 4 ***

Total number of credit hours: 7
*** Grades are being held for not paying the tuition. ***
Amount Due: $3941.00
_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*

Student Name: Samuel Sue
Student ID: D33889922
Number of courses enrolled: 3

Course Num Course Name Credits Grade
CSC478 ComputerSci 3 A
HIS356 History 3 C
PHY357 Physics 3 C

Total number of credit hours: 9
Mid-Semester GPA: 2.67
_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*

It is clear from this output that the courses must be ordered according to the course number. To calculate the GPA, we assume that the grade A is equivalent to 4 points, B 3 points, C 2 points, D 1 point, and F 0 points.

To write the program you need to identify the main components. The university has students, and every student takes courses. Thus, the two main components are the student and the course. You will need to create a Course class whose attribute variables are the course name, course number, the number of credit hours and the course grade. Some of the basic operations that need to be performed on an object of the Course class are: print the course information, show the credit hours, show the course name, show the course number and show the grade. Create methods in the Course class to do that.

Next you will need to create a Student class which inherits from the Person class. The attribute variables of the Person class are first and last name. Create methods in the Person class to get the first name and last name. The Student class has the following attribute variables: student ID, number of courses taken, is the tuition paid, and a 6 element array of Course pointers. Some of the basic operations that need to be performed on an object of the Student class are: print the student's information, calculate the number of credit hours taken, calculate the GPA, calculate the billing amount, and because the grade report will print the courses in ascending order, sort the courses according to the course number. You will need a way to add a course to a student object. Pass it the address of the Course object you dynamically create in the GetStudentData function. Create methods in the Student class to do that. The print methods in both the Course and Student classes will write the data to an output file. Here is the UML Design Class Diagram for lab 4.



Now that we have discussed the classes you will need in the program, lets talk about main(). We will restrict our program to process a maximum of 10 students. Set this up as a constant declared before main. Because the Print methods of the classes do the necessary calculations and print responsibilities, the main program has very little work to do. In fact all that is left for the main program is to declare the objects to hold the students' data, load the data into the objects from the data read from the file, and then print the grade reports. Because the input is in a file and the output will be sent to a file, we declare stream variables to access the input and output files. Essentially, the main algorithm for the program is:
1. Declare the variables including an array of Student pointers.
2. Open the input file.
3. If the input file does not exist, display an error message and exit the program.
4. Open the output file.
5. Get the number of students registered and the tuition rate.
6. Validate that the number of students is not greater than the maximum number of students.
7. Load the data from the file and create the Student and Course objects.
8. Print the grade reports.
9. Close the files.

I wrote two functions that I called from main: GetStudentData and PrintGradeReports.

Pseudocode for the GetStudentData:
Declare variables

Using a for loop input the data for each student
Dynamically create a Student object and assign it's address to the array
Using a for loop input the data for each course
Dynamically create a Course object
Call the AddCourse method in the Student class passing it
the index position where you want it to go and the address of
the newly created Course object
End-For
Sort the courses for the student
End-For

Pseudocode for the PrintGradeReports:
Using a for loop
Call the Print method for each student
End-For

Pseudocode for the Print method in the Student class
Output the student's information
For each course the student is taking
Call the Print method in the Course class
If the tuition is paid
Output the course grade
Else
Output ***
End-If
End-For
Output the number of credit hours
If the tuition has been paid
Calculate the GPA and output it
Else
Output the message and the amount of tuition the student owes
End-If

This post was edited by BouAnCafe on Nov 25 2012 11:59pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Nov 26 2012 12:19am
How much are you offering?
Member
Posts: 4,332
Joined: Mar 31 2011
Gold: 71.00
Nov 26 2012 12:38am
Quote (carteblanche @ Nov 26 2012 01:19am)
How much are you offering?


name your price. i need it done in 24 hours.
Member
Posts: 9,803
Joined: Jun 28 2005
Gold: 6.67
Nov 26 2012 03:13am
I can do this before the deadline. PM sent.
Member
Posts: 23,261
Joined: Dec 17 2006
Gold: 18,129.00
Nov 26 2012 06:35am
Hell, your teacher already wrote half of it for you :lol:
Member
Posts: 4,332
Joined: Mar 31 2011
Gold: 71.00
Nov 26 2012 12:51pm
Quote (PureOwnage2 @ Nov 26 2012 07:35am)
Hell, your teacher already wrote half of it for you :lol:


i'm just busy with work. they gave me 52 hours this week (12 hours of overtime) and i just don't have the time to do it... when i do have the time i'm exhausted.

This post was edited by BouAnCafe on Nov 26 2012 12:51pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll