Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a C++ program to get student data and create student report. This is an application to completely define the Student class and generate

Please write a C++ program to get student data and create student report. This is an application to completely define the Student class and generate student report for the user.

Each student must have the following 5 attributes (i.e., instance variables, or fields)

  1. studentID # students ID such as 1
  2. lastName # students last name such as Doe
  3. firstName # students first name such as John
  4. gpa # students GPA such as 3.45
  5. phoneNumber # students phone number such as 323-415-5476

Under the Student class, you must also define __str__(self) function to return the string representation of the student record because your statement print( student ) would call __str__(self) automatically.

Your main( ) function must use the following 3 variables with proper initial values:

countStudents = 0 # count the total number of students being constructed

totalGpa = 0.0 # total GPA summation of all students

averageGpa = 0.0 # average GPA of all students

Your main( ) function must do all the following:

  1. keep adding a new student, and printing the new student record.
  2. countStudents += 1 # increment the student count by one since we just added a new student
  3. update the current GPA total and GPA average properly as follows:

totalGpa += gpa # add this students gpa to totalGpa

averageGpa = totalGpa / countStudents # computer current average Gpa

In your main( ) function, you must write a while (studentID != 0) : # loop to keep asking the user to enter student id, last name, first name, GPA, and phone number. Then, you print the student record nicely, and show the current student count, total GPA, and average GPA. You must also print all the student records. Then, you continue asking the user to enter next students data. If the new student id is 0 (i.e., zero), please thank the user and stop your program nicely.

How to store all the student records and print them nicely in your main( ) function?

You may use the following statement to create an empty list called slist.

slist = [ ] # an empty list to start

You may use the following statement to add a student record to slist.

slist.append ( [sID, lastN, firstN, gpa, phone] ) # add a student record

You may use the following for loop to print all student records nicely.

for i in range (len ( slist ) ) :

print( slist[ i ] ) # print student i record

The output of your test case #1 must be as follows.

========================================================================.

Welcome to the program of "your name"

Please enter first student ID: 1

Please enter last name: Doe

Please enter first name: John

Please enter GPA: 3.0

Please enter phone number: 626-111-5428

You just entered the following student record:

Student ID: 1

Last Name: Doe

First Name: John

GPA: 3.0

Phone Number: 626-111-5428

========= CURRENT REPORT OF ALL STUDENTS ===============

Current Student Count = 1

Total GPA of all students = 3.0

Average GPA of all students = 3.0

All student records are as follows:

[1, 'Doe', 'John', 3.0, '626-111-5428']

========= END OF REPORT ====================+===========

Please enter next student ID: 2

Please enter last name: Smith

Please enter first name: Mary

Please enter GPA: 4.0

Please enter phone number: 626-222-5555

You just entered the following student record:

Student ID: 2

Last Name: Smith

First Name: Mary

GPA: 4.0

Phone Number: 626-222-5555

========= CURRENT REPORT OF ALL STUDENTS ===============

Current Student Count = 2

Total GPA of all students = 7.0

Average GPA of all students = 3.5

All student records are as follows:

[1, 'Doe', 'John', 3.0, '626-111-5428']

[2, 'Smith', 'Mary', 4.0, '626-222-5555']

========= END OF REPORT ====================+===========

Please enter next student ID: 3

Please enter last name: Stone

Please enter first name: Joe

Please enter GPA: 2.0

Please enter phone number: 626-333-5555

You just entered the following student record:

Student ID: 3

Last Name: Stone

First Name: Joe

GPA: 2.0

Phone Number: 626-333-5555

========= CURRENT REPORT OF ALL STUDENTS ===============

Current Student Count = 3

Total GPA of all students = 9.0

Average GPA of all students = 3.0

All student records are as follows:

[1, 'Doe', 'John', 3.0, '626-111-5428']

[2, 'Smith', 'Mary', 4.0, '626-222-5555']

[3, 'Stone', 'Joe', 2.0, '626-333-5555']

========= END OF REPORT ====================+===========

Please enter next student ID: 4

Please enter last name: Lin

Please enter first name: Steve

Please enter GPA: 1.0

Please enter phone number: 626-444-4444

You just entered the following student record:

Student ID: 4

Last Name: Lo

First Name: Steve

GPA: 1.0

Phone Number: 626-444-4444

========= CURRENT REPORT OF ALL STUDENTS ===============

Current Student Count = 4

Total GPA of all students = 10.0

Average GPA of all students = 2.5

All student records are as follows:

[1, 'Doe', 'John', 3.0, '626-111-5428']

[2, 'Smith', 'Mary', 4.0, '626-222-5555']

[3, 'Stone', 'Joe', 2.0, '626-333-5555']

[4, 'Lo', 'Steve', 1.0, '626-444-4444']

========= END OF REPORT ====================+===========

Please enter next student ID: 5

Please enter last name: Liken

Please enter first name: Pete

Please enter GPA: 3.0

Please enter phone number: 626-555-6666

You just entered the following student record:

Student ID: 5

Last Name: Liken

First Name: Pete

GPA: 3.0

Phone Number: 626-555-6666

========= CURRENT REPORT OF ALL STUDENTS ===============

Current Student Count = 5

Total GPA of all students = 13.0

Average GPA of all students = 2.6

All student records are as follows:

[1, 'Doe', 'John', 3.0, '626-111-5428']

[2, 'Smith', 'Mary', 4.0, '626-222-5555']

[3, 'Stone', 'Joe', 2.0, '626-333-5555']

[4, 'Lo', 'Steve', 1.0, '626-444-4444']

[5, 'Liken', 'Pete', 3.0, '626-555-6666']

========= END OF REPORT ====================+===========

Please enter next student ID: 6

Please enter last name: Bee

Please enter first name: Scott

Please enter GPA: 4.0

Please enter phone number: 323-666-6666

You just entered the following student record:

Student ID: 6

Last Name: Bee

First Name: Scott

GPA: 4.0

Phone Number: 323-666-6666

========= CURRENT REPORT OF ALL STUDENTS ===============

Current Student Count = 6

Total GPA of all students = 17.0

Average GPA of all students = 2.8333333333333335

All student records are as follows:

[1, 'Doe', 'John', 3.0, '626-111-5428']

[2, 'Smith', 'Mary', 4.0, '626-222-5555']

[3, 'Stone', 'Joe', 2.0, '626-333-5555']

[4, 'Lin', 'Steve', 1.0, '626-444-4444']

[5, 'Li', 'Pete', 3.0, '626-555-6666']

[6, 'Bee', 'Scott', 4.0, '323-666-6666']

========= END OF REPORT ====================+===========

Please enter next student ID: 7

Please enter last name: Codd

Please enter first name: April

Please enter GPA: 3.80

Please enter phone number: 323-777-7777

You just entered the following student record:

Student ID: 7

Last Name: Codd

First Name: April

GPA: 3.8

Phone Number: 323-777-7777

========= CURRENT REPORT OF ALL STUDENTS ===============

Current Student Count = 7

Total GPA of all students = 20.8

Average GPA of all students = 2.9714285714285715

All student records are as follows:

[1, 'Doe', 'John', 3.0, '626-111-5428']

[2, 'Smith', 'Mary', 4.0, '626-222-5555']

[3, 'Stone', 'Joe', 2.0, '626-333-5555']

[4, 'Lin', 'Steve', 1.0, '626-444-4444']

[5, 'Li', 'Pete', 3.0, '626-555-6666']

[6, 'Bee', 'Scott', 4.0, '323-666-6666']

[7, 'Codd', 'April', 3.8, '323-777-7777']

========= END OF REPORT ====================+===========

Please enter next student ID: 0

Thank you for using program designed by "Your name"

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

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions

Question

1. Define and explain culture and its impact on your communication

Answered: 1 week ago