-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask3.cpp
More file actions
56 lines (42 loc) · 1.32 KB
/
task3.cpp
File metadata and controls
56 lines (42 loc) · 1.32 KB
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
//TASK-->3
// STUDENT GRADING SYSTEM
/*Create a program that manages student grades. Allow the user
to input student names and their corresponding grades.
Calculate the average grade and display it along with the highest
and lowest grades*/
#include<iostream>
#include<string>
#include<vector>
using namespace std;
struct student{
string name;
double grade;
};
int main(){
vector<student> students;
string name;
double grade;
char option;
do{
cout<<"enter student name: ";
cin>>name;
cout <<"enter grade for "<<name<<" :";
cin>>grade;
students.push_back({name,grade});
cout<<"do you want to enter another student? (y/n): "<<endl;
}while(option=='y' || option=='Y');
double totalGrade=0;
double highestGrade =students[0].grade;
double lowestGrade=students[0].grade;
for(const auto& students : students){
totalGrade+=students.grade;
if(students.grade > highestGrade){
highestGrade=students.grade;
}else lowestGrade=students.grade;
}
double averageGrade = totalGrade/students.size();
cout<<"average Grade -->"<<averageGrade<<endl;
cout<<"highest Grade: "<<highestGrade<<endl;
cout<<"lowest Grade: "<<lowestGrade<<endl;
return 0;
}