aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortill-t <[email protected]>2021-10-20 16:40:36 -0700
committertill-t <[email protected]>2021-10-20 16:40:36 -0700
commit63f50a45df411f9ed7511bc49f7853bd3d6b3536 (patch)
tree4ede86f9eb91d6e564a00131685dd84d530e0359
parentAdd online IDE url (diff)
downloadcst116-lab4-till-t-63f50a45df411f9ed7511bc49f7853bd3d6b3536.tar.xz
cst116-lab4-till-t-63f50a45df411f9ed7511bc49f7853bd3d6b3536.zip
End of day. Complete through 9.3 exercises.
-rw-r--r--.idea/.gitignore8
-rw-r--r--.idea/cst116-lab4-till-t.iml8
-rw-r--r--.idea/misc.xml6
-rw-r--r--.idea/modules.xml8
-rw-r--r--.idea/vcs.xml6
-rw-r--r--CST116F2021-Lab4/Lab4_Taormina166
6 files changed, 202 insertions, 0 deletions
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/cst116-lab4-till-t.iml b/.idea/cst116-lab4-till-t.iml
new file mode 100644
index 0000000..bc2cd87
--- /dev/null
+++ b/.idea/cst116-lab4-till-t.iml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="CPP_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$" />
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..26363b8
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$/CST116F2021-Lab4">
+ <contentRoot DIR="$PROJECT_DIR$" />
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..a266524
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/cst116-lab4-till-t.iml" filepath="$PROJECT_DIR$/.idea/cst116-lab4-till-t.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
+ </component>
+</project> \ No newline at end of file
diff --git a/CST116F2021-Lab4/Lab4_Taormina b/CST116F2021-Lab4/Lab4_Taormina
new file mode 100644
index 0000000..787f66a
--- /dev/null
+++ b/CST116F2021-Lab4/Lab4_Taormina
@@ -0,0 +1,166 @@
+Tyler Taormina Lab 4 Text File
+CST CST116
+October 20, 2021
+
+7a
+6.8 Exercises
+pp 132-133
+5 pts #1-9
+Submit: value of “a” after the expression is executed
+________________________________________________________________________________________________________________________
+1. a = sqrt( 9.0); a = 3
+2. a = sqrt (-9.0); a = nan
+3. a = pow( 2.0, 5 ); a = 32
+4. a = pow ( 2.0, -2 ); a = 0.25
+5. a = ceil( 5.1 ); a = 6
+6. a = ceil( 5.9 ); a = 6
+7. a = floor( 5.1 ); a = 5
+8. a = floor( 5.9 ); a = 5
+9. a = sqrt( pow( abs( -2 ), 4 ) ); a = 4
+
+
+________________________________________________________________________________________________________________________
+9.3 Exercises
+p 207
+10 pts #1
+Submit: code & run
+Total: 15 pts
+
+
+#include <iostream>
+#include <cmath> // needed for square roots
+using namespace std;
+
+int avg_score (float& num1, float& num2, float& num3)
+{
+ int avg = 0;
+ avg = ( num1 + num2 + num3 ) / 3;
+ return avg;
+}
+
+int main() {
+
+ float value1, value2, value3, average = 0.0;
+
+ cout << "Enter 3 values that you want averaged." << endl;
+ cout << "Enter value 1: " << endl;
+ cin >> value1;
+ cout << "Enter value 2: " << endl;
+ cin >> value2;
+ cout << "Enter value 3: " << endl;
+ cin >> value3;
+
+ average = avg_score(value1, value2, value3);
+ cout << "Your average score is: " << average << endl;
+
+ return 0;
+}
+
+RUN:
+C:\Users\Till\CLionProjects\gitDemo\cmake-build-debug\gitDemo.exe
+Enter 3 values that you want averaged.
+Enter value 1:
+20
+Enter value 2:
+19
+Enter value 3:
+21
+Your average score is: 20
+
+Process finished with exit code 0
+
+________________________________________________________________________________________________________________________
+7b
+9.4 Learn by Doing Exercises
+p 214
+10 pts #1
+Submit: code & runs
+CODE:
+
+#include <iostream>
+using namespace std;
+
+void GetInput (float& salary, int& years_service)
+{
+ cout << "Enter salary: ";
+ cin >> salary;
+ cout << "Enter years_service: ";
+ cin >> years_service;
+}
+
+void CalcRaise (float& salary, int years_service)
+{
+ if (years_service > 10)
+ salary += (salary * .10);
+ else if (years_service >= 5)
+ salary += (salary * .05);
+ else
+ salary += (salary * .02);
+}
+
+
+int CalcBonus (int years_service)
+{
+ int bonus = 0;
+ int bonus_years = 0;
+ bonus_years = years_service / 2;
+ bonus = bonus_years * 500;
+ return bonus;
+}
+
+void PrintCalc (int years_service, float salary, int bonus)
+{
+ cout << "Employee years of service is " << years_service << endl;
+ cout << "Your current salary is $" << salary << endl;
+ cout << "The bonus you will receive is $" << bonus << endl;
+}
+
+int main()
+{
+ int years_service = 0, bonus = 0;
+ float salary = 0.0;
+
+ GetInput(salary, years_service);
+ CalcRaise(salary, years_service);
+ bonus = CalcBonus(years_service);
+ PrintCalc(years_service, salary, bonus);
+
+ return 0;
+}
+
+
+RUN:
+C:\Users\Till\CLionProjects\gitDemo\cmake-build-debug\gitDemo.exe
+Enter salary:20000
+ Enter years_service:10
+ Employee years of service is 10
+Your current salary is $21000
+The bonus you will receive is $2500
+
+Process finished with exit code 0
+________________________________________________________________________________________________________________________
+
+7c
+9.5 Learn by Doing Exercises
+p 216
+10 pts #2
+Submit: code & run
+
+
+
+
+
+________________________________________________________________________________________________________________________
+8a
+9.13 Debugging Exercises
+pp 226-229
+10 pts #1
+Submit: code & runs
+
+8b
+9.14 Programming Exercises
+pp 229
+10 pts #1
+Submit: code & run
+
+Total: 55 pts \ No newline at end of file