-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitchOperatorDEMO2.cpp
More file actions
42 lines (38 loc) · 1.12 KB
/
Copy pathSwitchOperatorDEMO2.cpp
File metadata and controls
42 lines (38 loc) · 1.12 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
//************************************************************************
// Author: Rolando Carreon
// Date: feb 13 2025
// Language: C++
// Assignment: Switch Operator DEMO 2
// Description: give feedback to student based on their letter grade
//************************************************************************
#include<iostream>
using namespace std;
int main()
{
// declare local variables //
// char uses single qoutes, string uses double qoutes
// case sensitive, lowcase is not the same as uppercase, wont understand //
char grade = 'B';
// switch on the grade to give feedback //
switch(grade)
{
case 'A':
cout << "Excellent!\n";
break;
// B & C will execute the same stuff, B has nothing so it falls thru to C
case 'B':
case 'C':
cout << "Well Done.\n";
break;
case 'D':
cout << "You passed.\n";
break;
case 'F':
cout << "Better try again.\n";
break;
default:
cout << "Invalid grade.\n";
break;
}
return 0;
}