-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule3SemesterProjectTemplate.cpp
More file actions
120 lines (109 loc) · 4.29 KB
/
Copy pathModule3SemesterProjectTemplate.cpp
File metadata and controls
120 lines (109 loc) · 4.29 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
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
//************************************************************************
// Author: Rolando Rey Carreon
// Date: feb 28 2025
// Language: C++
// Assignment: Module 3 Semester Project - RESENT
// Description: My Objective this section will be to add a Switch
// statement Menu to prompt the user to make a selection.
// The selection choice that they make will determine the
// functionality the program will execute.
//************************************************************************
// START OF SEMESTER 1 PROJECT */ MODIFIED ON 02/28 /* //
#include<iostream>
#include<iomanip> // added iomanip
#include<cmath> // added cmath
using namespace std;
int main()
{
// declare local variables
string firstName, lastName;
// display course information, prompt for first and last name
cout << "****************************************\n"
<< "* Programming 1 Course Project *\n"
<< "****************************************\n"
<< "Please enter your first name: ";
cin >> firstName;
cout << "Please enter your last name: ";
cin >> lastName;
// displays welcome message with input first name
cout << "Welcome to my course project " << firstName << "!" << endl;
// START OF SEMESTER 2 PROJECT */ MODIFIED ON 02/28 /* //
// added cmath
// new varibles declared //
int choice; // user choice value
int sqrtValue; // square root variables
int sqrtResult;
int xValue; // base and exponent variables
int yValue;
int powResult;
double GPA; // GPA variable
// prompts user to choose a request 0-3
cout << "****************************************\n"
<< "Enter 1 to Calculate Square Root\n"
<< "Enter 2 to Enter X to the Y Power\n"
<< "Enter 3 to Convert Numerical GPA to a Letter Grade\n"
<< "Enter 0 to Exit\n"
<< "Enter Your Request: ";
cin >> choice;
// switch that uses 4 cases based on user choice
switch (choice)
{
// prompts user to enter a number to square root
case 1:
cout << "Enter a number to calculate the Square Root: ";
cin >> sqrtValue;
sqrtResult = sqrt(sqrtValue); // square root function
// displays square root result
cout << "The Square Root of " << sqrtValue << " is "
<< sqrtResult << endl;
break; // breaks out of switch
// prompts user to enter a number to raise
case 2:
cout << "Enter a number X to raise to the Y Power\n"
<< "Enter X: ";
cin >> xValue;
cout << "Enter Y: ";
cin >> yValue;
powResult = pow(xValue, yValue); // exponent function
// displays exponent result
cout << xValue << " to the " << yValue << " power is "
<< powResult << endl;
break;
// prompts user to enter a numerical grade value
case 3:
cout << "Enter your numerical Grade (GPA): ";
cin >> GPA;
// determines either 5 letter grade base on user input
// grade value greater than or equal to 3.7 list as A
if (GPA >= 3.7)
{
cout << "Letter Grade is an A" << endl;
}
// grade value greater than or equal to 2.7 list as B
else if (GPA >= 2.7)
{
cout << "Letter Grade is an B" << endl;
}
// grade value greater than or equal to 1.7 list as C
else if (GPA >= 1.7)
{
cout << "Letter Grade is an C" << endl;
}
// grade value greater than or equal to 0.7 list as D
else if (GPA >= 0.7)
{
cout << "Letter Grade is an D" << endl;
}
// grade value below 0.7 list as F
else
{
cout << "Letter Grade is an F" << endl;
}
break;
// exit statment displayed if no intended options chosen
default:
cout << "Thank you for using my project" << endl;
break;
} // end of switch statment
return 0;
}