aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab4
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 /CST116F2021-Lab4
parentAdd online IDE url (diff)
downloadarchived-cst116-lab4-till-t-63f50a45df411f9ed7511bc49f7853bd3d6b3536.tar.xz
archived-cst116-lab4-till-t-63f50a45df411f9ed7511bc49f7853bd3d6b3536.zip
End of day. Complete through 9.3 exercises.
Diffstat (limited to 'CST116F2021-Lab4')
-rw-r--r--CST116F2021-Lab4/Lab4_Taormina166
1 files changed, 166 insertions, 0 deletions
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