-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule2SemesterProject.cpp
More file actions
164 lines (151 loc) · 5.53 KB
/
Copy pathModule2SemesterProject.cpp
File metadata and controls
164 lines (151 loc) · 5.53 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//************************************************************************
// Author: Rolando Rey Carreon
// Date: feb 13 2025
// Language: C++
// Assignment: Module 2 Semester Project
// 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-2 PROJECT //
//
#include<iostream>
// added iomanip //
#include<iomanip>
// added cmath for Sem. 2 Project //
#include<cmath>
using namespace std;
int main()
{
// declare local variables //
// format string is 40 characters long, used more than once //
string formatString = "****************************************\n";
// assuming this string will be used allot, used more than once //
string pleaseEnter = "Please enter your ";
// user defined string variables //
string firstName, lastName;
// formatted line by line as seen by user //
cout << formatString
<< "* Programming 1 Course Project *\n"
<< formatString
// first prompt //
<< pleaseEnter << "first name: ";
// user enters string variable //
cin >> firstName;
// second prompt //
cout << pleaseEnter << "last name: ";
// user enters string variable //
cin >> lastName;
// ending message using user inputs from prompt 1 //
cout << "Welcome to my course project " << firstName << "!" << endl;
//
// END OF SEMESTER 1 PROJECT // added cmath for Sem.2P
//
//
// START OF SEMESTER 2 PROJECT
//
// new varibles declared //
// prompts user to enter a request value //
int userRequest;
// request 1 square root variables //
int userSqrt;
int resultSqrt;
// request 2 base and exponent variables //
int userXValue;
int userYValue;
int resultXYPow;
// request 3 numerical GPA variable //
double userGrade;
// prompts user to choose request value 0-3 //
cout << "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: ";
// user enters int variable 0-3 //
cin >> userRequest;
// if else if statment that uses variables 1-3 based on user choice, if
// other then exit program //
// starting from top to bottom, if user request variable is 1 then
// run this and ends statement after //
if (userRequest == 1)
{
// prompts user to enter square root value //
cout << "Enter a number to calculate the Square Root:";
// user enters int variable //
cin >> userSqrt;
// square root function takes user variable and saves answer to
// result new int variable //
resultSqrt = sqrt(userSqrt);
// displays square root result based on the user variable //
cout << "The Square Root of " << userSqrt << " is "
<< resultSqrt << endl;
}
// if user request variable is not 1 but is 2 then run this and ends
// statement after //
else if (userRequest == 2)
{
// prompts user to enter base value //
cout << "Enter a number X to raise to the Y Power\n"
<< "Enter X: ";
// user enters int variable //
cin >> userXValue;
// prompts user to enter another exponent value
cout << "Enter Y: ";
// user enters int variable //
cin >> userYValue;
// exponent function takes user base and exponent variable and
// saves answer to result new int variable //
resultXYPow = pow(userXValue, userYValue);
// displays exponent result based on the user variables //
cout << userXValue << " to the " << userYValue
<< " power is " << resultXYPow << endl;
}
// if user request variable is not 1 or 2 but is 3 then run this and
// ends statement after //
else if (userRequest == 3)
{
// prompts user to enter numerical grade value //
cout << "Enter your numerical Grade: ";
// user enters double variable //
cin >> userGrade;
// inside of if else if == 3 is another if else if statement in order to
// determine either 5 letter grade base on user double variable //
// if user grade value greater than or equal to 3.7 list as A //
if (userGrade >= 3.7)
{
cout << "Letter Grade is an A" << endl;
}
// if user grade value greater than or equal to 2.7 list as B //
else if (userGrade >= 2.7)
{
cout << "Letter Grade is an B" << endl;
}
// if user grade value greater than or equal to 1.7 list as C //
else if (userGrade >= 1.7)
{
cout << "Letter Grade is an C" << endl;
}
// if user grade value greater than or equal to 0.7 list as D //
else if (userGrade >= 0.7)
{
cout << "Letter Grade is an D" << endl;
}
// if user grade value below 0.7 list as F //
else
{
cout << "Letter Grade is an F" << endl;
}
// if else if statement #2 ends //
}
// if user request variable is not 1-3 then display exit statement //
else
{
// exit statment displayed if no intended options chosen //
cout << "Thank you for using my project" << endl;
}
// if else if statement #1 ends //
return 0;
}