Fixed up files
[interests.git] / mycodes / lovepython.cc
blobe694d33f8c0d4c0f7d808dd03f03d096113919d0
1 #include <iostream>
2 #include <string>
3 #include <iomanip>
5 using namespace std;
7 /*TEST 1
9 Requirements:
11 Create a class called STUDENT with data members firstname, lastname, age finalcwgrade and
12 finalexgrade and studentID.
13 Use a default constructor to initialize firstname to “Usain” and lastname to “Bolt”. Initialize
14 all other data members to zero.
15 Define a mutator that will accept values for the data members from the user and update each data
16 member.
17 Define a function CalculateFinalGrade that will sum the final coursework grade and the final exam
18 grade and return the average of both grades.
19 Define a utility function that will check if the final grade is above 80, and prints the message
20 “This student is above average”. If the final grade is not above 80, then your program should
21 display “ This is an Average Student” This utility should be invoked by a display function.
22 The display function will display all the student’s information and whether or not the student is
23 average or above average.
24 Finally, write a main program that will implement the student class. Invoke the display function
25 before the user enters inputs to display default constructor values and should also be invoked
26 after the user inputs.
29 class Student {
30 private:
31 string firstname, lastname;
32 static int age, studentID;
33 static float finalcwgrade, finalexgrade, finalgrade;
34 public:
35 Student(){
36 firstname = "Usain";
37 lastname = "Bolt";
39 void setStudent(string fname, string lname, int ag, int stID, float cw, float ex){
40 firstname = fname;
41 lastname = lname;
42 age = ag;
43 studentID = stID;
44 finalcwgrade = cw;
45 finalexgrade = ex;
47 float CalculateFinalGrade(){
48 finalgrade = (finalcwgrade + finalexgrade) / 2;
49 return finalgrade;
51 string PerfTest(){
52 if(finalgrade > 80){
53 string assess = "This student is above average";
54 return assess;
56 else
58 string assess = "This is an Average Student";
59 return assess;
62 void Display(){
63 cout << setw(5) << "First Name" << setw(10) << "Last Name" << setw(5) << "Age" << setw(10)
64 << "StudentID" << setw(10) << "CW Grade" << setw(12) << "Exam Grade" << setw(12) <<
65 "Final Grade" << setw(10) << "Status" << endl;
66 cout << setw(5) << firstname << setw(10) << lastname << setw(8) << age << setw(10) <<
67 studentID << setw(10) << finalcwgrade << setw(10) << finalexgrade << setw(10);
68 cout << CalculateFinalGrade();
69 cout << setw(36);
70 cout << PerfTest();
71 cout << endl << endl;
75 int Student::age = 0;
76 int Student::studentID = 0;
77 float Student::finalcwgrade = 0.0;
78 float Student::finalexgrade = 0.0;
79 float Student::finalgrade = 0.0;
82 int main(){
83 Student stud;
84 string fname, lname;
85 int age, stID;
86 float cw, ex;
88 stud.Display();
90 cout << "Enter First Name: \t";
91 cin >> fname;
92 cout << endl << endl << "Enter Last Name: \t";
93 cin >> lname;
94 cout << endl << endl << "Enter Age: \t";
95 cin >> age;
96 cout << endl << endl << "Enter StudentID: \t";
97 cin >> stID;
98 cout << endl << endl << "Enter Final Coursework Grade: \t";
99 cin >> cw;
100 cout << endl << endl << "Enter Final Exam Grade: \t";
101 cin >> ex;
103 cout << endl;
104 stud.setStudent(fname, lname, age, stID, cw, ex);
106 cout << endl;
107 stud.Display();
109 cin.ignore();
110 cin.get();
112 return 0;