aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab3
diff options
context:
space:
mode:
Diffstat (limited to 'CST116F2021-Lab3')
-rw-r--r--CST116F2021-Lab3/Lawrance CST116-Lab3.cpp170
1 files changed, 167 insertions, 3 deletions
diff --git a/CST116F2021-Lab3/Lawrance CST116-Lab3.cpp b/CST116F2021-Lab3/Lawrance CST116-Lab3.cpp
index 314a503..4acfc14 100644
--- a/CST116F2021-Lab3/Lawrance CST116-Lab3.cpp
+++ b/CST116F2021-Lab3/Lawrance CST116-Lab3.cpp
@@ -69,6 +69,9 @@ using namespace std;
// }
//}
+
+//5c
+//7.10 Exercises #2
//int main()
//{
//variables
@@ -98,9 +101,9 @@ using namespace std;
//calculating fees
// if (amountOfLoan <= 500 || amountOfLoan >= 100)
- fee = 20;
+ //fee = 20;
// if (amountOfLoan > 500)
- fee = 25;
+ //fee = 25;
//outputting data
// cout << "The total amount of interest due is ";
@@ -113,4 +116,165 @@ using namespace std;
// cout << (amountOfLoan * interestRate) + fee << endl;
// return 0;
-// } \ No newline at end of file
+// }
+
+//6b
+//Section 8.4
+//#1
+int main()
+{
+//defining variables
+ int numOfAssignments = 0; int gradedAssignments = 0; float score; float scoreAccumulate = 0; float averageScore; int numCount = 1;
+//user prompt and input
+ cout << "Enter the number of assignments" << endl;
+ cin >> numOfAssignments;
+ gradedAssignments = numOfAssignments;
+ cout << endl;
+//get each assignment score
+ for (numOfAssignments; numOfAssignments > 0; numOfAssignments--)
+ {
+ cout << "Enter the score for Assignment #" << numCount << endl;
+ cin >> score;
+ scoreAccumulate = scoreAccumulate + score;
+ numCount++;
+ }
+//calculate average score
+ averageScore = (scoreAccumulate / gradedAssignments);
+//print average score
+ cout << "The average score of these " << gradedAssignments << " assignments is " << averageScore;
+}
+
+// Section 8.4
+// #2
+
+//int main()
+//{
+ //defining variables
+ //int baseLength = 0;
+
+ //asking for input
+ //cout << "Base length?" << endl;
+ //cin >> baseLength;
+ //cout << endl;
+
+ //executing loops to create triangle
+ //for (int b = baseLength; b <= baseLength, b != 0; b--)
+ //{
+ //for (int a = b; a != 0; a--)
+ //{
+ //cout << '*';
+ //}
+ //cout << endl;
+ //}
+
+ //return 0;
+//}
+
+//Section 8.10 #3
+
+//int main()
+//{
+// int endValue = 0; int currentValue = 1; int behind_currentValue = 0; int currentBehindSum = 1;
+
+// cout << "Where would you like your Fibonacci sequence to terminate?\n";
+// cin >> endValue;
+// cout << endl;
+
+// while (currentValue <= endValue)
+// {
+// cout << currentBehindSum << ' ';
+// currentBehindSum = currentValue + behind_currentValue;
+
+// behind_currentValue = currentValue;
+// currentValue = currentBehindSum;
+
+// }
+
+// cout << endl;
+// return 0;
+//}
+
+//6a
+//Section 8.2 # 1
+
+//int main()
+//{
+// //defining variables
+// int startValue = 0;
+ //user prompt
+// cout << "Welcome to the descending even number program.\nPlease enter an integer between 1 and 50\n";
+// cin >> startValue;
+// cout << endl;
+// //end program if startValue not 1-50
+// if ((startValue < 50) && (startValue > 1))
+// {
+// }
+// else
+// {
+// cout << "The number you have entered is not between 1 and 50. Try again." << endl;
+// return 0;
+// }
+// //check if startValue is odd, print once if odd skip if even
+// if ((startValue % 2) != 0)
+// {
+// cout << startValue;
+// cout << endl;
+// }
+// //calculations and display loop
+// for (startValue; (startValue >= 0); startValue--)
+// {
+// if ((startValue % 2) == 0)
+// {
+// cout << startValue << ' ';
+// }
+// else
+// {
+// }
+// }
+
+// cout << endl;
+// return 0;
+
+//}
+
+//Section 8.3 #1
+
+//int main()
+//{
+//defining variables
+//int startValue = 0;
+//user prompt and check if number is 1-50
+//cout << "Welcome to the descending even number program.\nPlease enter an integer between 1 and 50\n";
+//cin >> startValue;
+//cout << endl;
+//if ((startValue > 50) || (startValue < 1))
+//{
+// do
+// {
+// cout << "You have not entered an integer between 1 and 50. Please try again.\n";
+// cin >> startValue;
+// cout << endl;
+// } while ((startValue > 50) || (startValue < 1));
+//}
+//check if startValue is odd, print once if odd skip if even
+//if ((startValue % 2) != 0)
+//{
+// cout << startValue;
+// cout << endl;
+//}
+//calculations and display loop
+//for (startValue; (startValue >= 0); startValue--)
+//{
+// if ((startValue % 2) == 0)
+// {
+// cout << startValue << ' ';
+// }
+// else
+// {
+// }
+//}
+
+//cout << endl;
+//return 0;
+
+//} \ No newline at end of file