-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomFunction.cpp
More file actions
37 lines (32 loc) · 890 Bytes
/
Copy pathcustomFunction.cpp
File metadata and controls
37 lines (32 loc) · 890 Bytes
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
//Lab 4 Custom Function
#include <iostream>
using namespace std;
char getLetterGrade(int score, int curve);
int main()
{
// Declare variables for score and curve
int score, curve;
cout << "Enter the number grade: ";
cin >> score;
cout << "Enter the curve percentage(%): ";
cin >> curve;
// Call the function and display the result
char letterGrade = getLetterGrade(score, curve);
cout << "The letter grade is: " << letterGrade << endl;
return 0;
}
// Function to calculate the letter grade based on score and curve
char getLetterGrade(int score, int curve)
{
int curvedScore = score + (score * curve / 100);
if (curvedScore >= 90)
return 'A';
else if (curvedScore >= 80)
return 'B';
else if (curvedScore >= 70)
return 'C';
else if (curvedScore >= 60)
return 'D';
else
return 'F';
}