-
Notifications
You must be signed in to change notification settings - Fork 0
/
quizProblem1.cpp
67 lines (52 loc) · 1.28 KB
/
quizProblem1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Jairo Molina
* 23499086
* Fall 2018, CSC 211
* Tuesday, Sept 4 2018
* 7:00 PM
*
* Dr. Azhar
*/
#include <iostream>
using namespace std;
class StudentInfo {
private:
string name;
int credit;
public:
/*in-class prototype*/
void addCredits(int, string);
bool graduationReady(int);
void result()
{
if(graduationReady(credit) == 1) //denotes ready
{
cout << "\n" << name << " completed " << credit << " credits and can file for graduation\n" <<endl;
}
else //denotes false
cout << "\n" << name << " completed " << credit << " credits and needs " << 120-credit <<
" credits to graduate\n" << endl;
}
}; //check ';' after every class
void StudentInfo::addCredits(int number, string n)
{
name = n;
credit = number + 30; //add 30 credits
}
bool StudentInfo::graduationReady(int cred)
{
if(cred < 120) {return 0;} //flag denotes graduation requirement met
else{return 1;}
}
int main ()
{
string name;
int credits;
StudentInfo stud;
cout << "Enter name: " << endl;
cin >> name;
cout << "Enter credit: " << endl;
cin >> credit;
stud.addCredits(getCredit(), getName()); //values from functions passed as arguments
stud.result(); // display final result
}