diff options
| -rw-r--r-- | CST116F2021-Lab3/Lawrance CST116-Lab3.cpp | 170 | ||||
| -rw-r--r-- | Lab 3 Output and Work.txt | 112 |
2 files changed, 279 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 diff --git a/Lab 3 Output and Work.txt b/Lab 3 Output and Work.txt index 45ce85d..1bc42ff 100644 --- a/Lab 3 Output and Work.txt +++ b/Lab 3 Output and Work.txt @@ -119,3 +119,115 @@ Error: invalid loan amount C:\Users\there\Source\Repos\cst116-lab3-JEmersonLawrance\x64\Debug\CST116F2021-Lab3.exe (process 12340) exited with code 0. To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. Press any key to close this window . . . + +Section 8.4 #1 pseudocode - +Average Test Scores Program +Input number of Assignments +Loop asking for scores +Average Test Scores = Scores/Assignments +Print Average Test Scores + +Section 8.4 #1 output - + +Enter the number of assignments +7 + +Enter the score for Assignment #1 +100 +Enter the score for Assignment #2 +100 +Enter the score for Assignment #3 +98 +Enter the score for Assignment #4 +88 +Enter the score for Assignment #5 +75 +Enter the score for Assignment #6 +73 +Enter the score for Assignment #7 +73 +The average score of these 7 assignments is 86.7143 + +Section 8.4 #2 output - + +Base length? +16 + +**************** +*************** +************** +************* +************ +*********** +********** +********* +******** +******* +****** +***** +**** +*** +** +* + +C:\Users\there\source\repos\cst116-lab3-JEmersonLawrance\x64\Debug\CST116F2021-Lab3.exe (process 5076) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . + +Section 8.10 #3 - + +output 1- +Where would you like your Fibonacci sequence to terminate? +20 + +1 1 2 3 5 8 13 + +output 2- +Where would you like your Fibonacci sequence to terminate? +5000 + +1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 + +6a - +6.5 Exercises - + +1. a += 25 +2. b *- (a * 2) +3. ++b +4. c %= 5 +5. b /= a + +Section 8.2 #1 - + +output 1 - + +Welcome to the descending even number program. +Please enter an integer between 1 and 50 +50 + +The number you have entered is not between 1 and 50. Try again. + +output 2 - + +Welcome to the descending even number program. +Please enter an integer between 1 and 50 +15 + +15 +14 12 10 8 6 4 2 0 + +Section 8.3 #1 output- + +Welcome to the descending even number program. +Please enter an integer between 1 and 50 +0 + +You have not entered an integer between 1 and 50. Please try again. +100 + +You have not entered an integer between 1 and 50. Please try again. +14 + +14 12 10 8 6 4 2 + +0
\ No newline at end of file |