diff options
| author | [email protected] <[email protected]> | 2021-11-02 18:23:00 -0700 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2021-11-02 18:23:00 -0700 |
| commit | c27a2d68f59ac753e04bc2983b6c5ae3acca69b3 (patch) | |
| tree | 26871e00fdcd6a3c76caed61bbca8dbcef0ea8d6 | |
| parent | Add online IDE url (diff) | |
| download | cst116-lab5-rayyanansari03-c27a2d68f59ac753e04bc2983b6c5ae3acca69b3.tar.xz cst116-lab5-rayyanansari03-c27a2d68f59ac753e04bc2983b6c5ae3acca69b3.zip | |
Lab 5 answers V1
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.cpp | 20 | ||||
| -rw-r--r-- | LAB5-Ansari-Answers.txt | 128 |
2 files changed, 146 insertions, 2 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp index e7591f7..9e34b3d 100644 --- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp +++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp @@ -1,11 +1,27 @@ -// CST116F2021-Lab5.cpp : This file contains the 'main' function. Program execution begins and ends there. + // CST116F2021-Lab5.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include <iostream> +using namespace std; int main() { - std::cout << "Hello World!\n"; + //std::cout << "Hello World!\n"; + + char lastName[11]{}; + ///char firstname[11]{}; + //int z[11]{}; + + cin >> lastName; + + for (int x = 0; x < 10; x++) { + + cout << &lastName[x] << endl; + + } + + + } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu diff --git a/LAB5-Ansari-Answers.txt b/LAB5-Ansari-Answers.txt new file mode 100644 index 0000000..30a5672 --- /dev/null +++ b/LAB5-Ansari-Answers.txt @@ -0,0 +1,128 @@ +// LAB5 - ANSARI.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include <iostream> +using namespace std; +const int NUMSTUDENTS = 10; +const int NUMGRA = 5; + +int main() +{ + float scoreArray[NUMSTUDENTS] = { 0.0 }; + string gradeArray[NUMSTUDENTS]; + int numGradeArray[NUMGRA] = { 0 }; + float avg = 0.0; + for (int i = 0; i < NUMSTUDENTS; i++) { + + cout << "Enter score " << i + 1 << ": " << endl; + cin >> scoreArray[i]; + avg += scoreArray[i]; + + + + } + + for (int n = 0; n < NUMSTUDENTS; n++) { + + if (scoreArray[n] >= 92) { + + gradeArray[n] = "A"; + numGradeArray[0] += 1; + + } + + else if (scoreArray[n] >= 84) { + + gradeArray[n] = "B"; + numGradeArray[1] += 1; + + } + + else if (scoreArray[n] >= 75) { + + gradeArray[n] = "C"; + numGradeArray[2] += 1; + + } + else if (scoreArray[n] >= 65) { + + gradeArray[n] = "D"; + numGradeArray[3] += 1; + + } + + else { + + + gradeArray[n] = "F"; + numGradeArray[4] += 1; + + } + + } + + for (int x = 0; x < 10; x++) { + + cout << scoreArray[x] << " = " << gradeArray[x] << endl; + + } + + cout << "Average is: " << avg / 10 << endl; + + cout << "The amount of people that got an A, B, C, D, and F in order are listed below: " << endl; + + for (int y = 0; y < 5; y++) { + + cout << numGradeArray[y] << endl; + + } + + +} + +OUTPUT: + +Enter score 1: +65 +Enter score 2: +87 +Enter score 3: +98 +Enter score 4: +98 +Enter score 5: +98 +Enter score 6: +23 +Enter score 7: +12 +Enter score 8: +65 +Enter score 9: +78 +Enter score 10: +89 +65 = D +87 = B +98 = A +98 = A +98 = A +23 = F +12 = F +65 = D +78 = C +89 = B +Average is: 71.3 +The amount of people that got an A, B, C, D, and F in order are listed below: +3 +2 +1 +2 +2 + +C:\Users\ansar\source\repos\OIT Brushup\Debug\OIT Brushup.exe (process 13084) 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 . . . + +-------------------------------------------------------------------------------------------------------------- + |