-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStudentInfoStructure
137 lines (114 loc) · 2.4 KB
/
StudentInfoStructure
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
struct ContactInfo
{
string email;
string phoneNumber;
//Constructor
ContactInfo()
{
email = "";
phoneNumber = "";
}
};
struct student
{
string name;
int id;
float gpa;
bool likesCoffee;
string email;
// Constructor
student(string n, int i, float g, bool lc)
{
name = n;
id = i;
gpa = g;
likesCoffee = lc;
}
student(string n)
{
name = "";
id = -99;
gpa = 0.0;
likesCoffee = true;
}
student()
{
name = "";
id = -99;
gpa = 0.0;
likesCoffee = true;
}
};
float ComputeAverageGPA(float gpa1, float gpa2, float gpa3);
void DisplayStudentInfo(student s1);
void InputStudentValue(student &s1);
void ComputeHighestGPA(student s1, student s2, student s3);
int main()
{
student Stud1;
Stud1.name = "Clinton";
Stud1.gpa = 5.0;
Stud1.likesCoffee = false;
Stud1.id = 9999;
student Stud2;
Stud2.name = "Carsen";
Stud2.gpa = 8.0;
Stud2.likesCoffee = true;
Stud2.id = 8888;
student Stud3 = { "test" };
//InputStudentValue(Stud3);
DisplayStudentInfo(Stud1);
DisplayStudentInfo(Stud2);
DisplayStudentInfo(Stud3);
ComputeHighestGPA(Stud1, Stud2, Stud3);
float AvgGPA = ComputeAverageGPA(Stud1.gpa, Stud2.gpa, Stud3.gpa);
cout << "The average GPA is... \n" << AvgGPA << endl;
cout << "Highest GPA\n";
ComputeHighestGPA(Stud1, Stud2, Stud3);
int c;
cin >> c;
return 0;
}
void DisplayStudentInfo(student s1)
{
cout << "Name: " << s1.name << endl;
cout << "ID: " << s1.id << endl;
cout << "GPA: " << s1.gpa << endl;
cout << "Likes Coffee: " << s1.likesCoffee << endl;
cout << "Email:" << s1.email << endl << endl;
}
void InputStudentValue(student &s1)
{
cout << "Please enter in a name\n";
cin >> s1.name;
cout << "Please enter in a n id number\n";
cin >> s1.id;
cout << "Please enter in a GPA\n";
cin >> s1.gpa;
string likesCoffee;
cout << "Do you like coffee (Y/N)\n";
cin >> likesCoffee;
if (likesCoffee == "Y")
s1.likesCoffee = true;
else
s1.likesCoffee = false;
}
float ComputeAverageGPA(float gpa1, float gpa2, float gpa3)
{
return (gpa1 + gpa2 + gpa3) / 3;
}
void ComputeHighestGPA(student s1, student s2, student s3)
{
if (s1.gpa > s2.gpa && s1.gpa > s3.gpa)
DisplayStudentInfo(s1);
else if (s2.gpa > s1.gpa && s2.gpa > s3.gpa)
DisplayStudentInfo(s2);
else
DisplayStudentInfo(s3);
}