-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule1Week2Option1Lab.cpp
More file actions
35 lines (31 loc) · 1.16 KB
/
Copy pathModule1Week2Option1Lab.cpp
File metadata and controls
35 lines (31 loc) · 1.16 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
//************************************************************************
// Author: Rolando Rey Carreon
// Date: feb 07 2025
// Language: C++
// Assignment: Module1Week2Option1Lab
// Description: Create a C++ program that computes the average of
// 5 test grades.
//************************************************************************
#include<iostream>
using namespace std;
int main()
{
// declare local variables //
// preset local grade values in int //
int grade1 = 82, grade2 = 85, grade3 = 98;
// or this way seperately? which way is better? //
int grade4 = 79;
int grade5 = 87;
// grade average must have float variable to have a decimal //
float gradeAverage;
// displays all grades as well as grade average to user //
cout << "Grade 1: " << grade1
<< "\nGrade 2: " << grade2
<< "\nGrade 3: " << grade3
<< "\nGrade 4: " << grade4
<< "\nGrade 5: " << grade5;
// adds all grades and divides by float number, avoids static float //
gradeAverage = (grade1 + grade2 + grade3 + grade4 + grade5) /5.0;
cout << "\nAverage Grade: " << gradeAverage << "\n" << endl;
return 0;
}