diff options
| author | till-t <[email protected]> | 2021-11-02 14:47:09 -0700 |
|---|---|---|
| committer | till-t <[email protected]> | 2021-11-02 14:47:09 -0700 |
| commit | c169e4210da63f8c8d37235fc8fdf56b44b6f278 (patch) | |
| tree | 99787a3bd7f4bd3a2765bb75c7e04599c5024c7f | |
| parent | Update (diff) | |
| download | cst116-lab5-till-t-c169e4210da63f8c8d37235fc8fdf56b44b6f278.tar.xz cst116-lab5-till-t-c169e4210da63f8c8d37235fc8fdf56b44b6f278.zip | |
Putting seperate modules in sep folders.
| -rw-r--r-- | mod_10a/main.cpp | 2 | ||||
| -rw-r--r-- | mod_10a/source.cpp | 2 | ||||
| -rw-r--r-- | mod_10a/source.h | 1 | ||||
| -rwxr-xr-x | mod_9b/a.out | bin | 0 -> 25624 bytes | |||
| -rw-r--r-- | mod_9b/main.cpp | 16 | ||||
| -rw-r--r-- | mod_9b/scores.h | 18 | ||||
| -rw-r--r-- | mod_9b/source.cpp | 84 |
7 files changed, 123 insertions, 0 deletions
diff --git a/mod_10a/main.cpp b/mod_10a/main.cpp new file mode 100644 index 0000000..38980a7 --- /dev/null +++ b/mod_10a/main.cpp @@ -0,0 +1,2 @@ +main.cpp + diff --git a/mod_10a/source.cpp b/mod_10a/source.cpp new file mode 100644 index 0000000..3070d67 --- /dev/null +++ b/mod_10a/source.cpp @@ -0,0 +1,2 @@ +source.cpp + diff --git a/mod_10a/source.h b/mod_10a/source.h new file mode 100644 index 0000000..b9b18ba --- /dev/null +++ b/mod_10a/source.h @@ -0,0 +1 @@ +source file diff --git a/mod_9b/a.out b/mod_9b/a.out Binary files differnew file mode 100755 index 0000000..2e33377 --- /dev/null +++ b/mod_9b/a.out diff --git a/mod_9b/main.cpp b/mod_9b/main.cpp new file mode 100644 index 0000000..3c1bb70 --- /dev/null +++ b/mod_9b/main.cpp @@ -0,0 +1,16 @@ +// Tyler Taormina +#include "scores.h" + + +int main() +{ + float currStudent[NUM_STUDENTS]{0.0}; + char LetterGrades[NUM_STUDENTS]; + float average_score = 0.0; + + ReadScores(currStudent); + LetterGrade(LetterGrades, currStudent); + average_score = calcAverage(currStudent); + printInfo(currStudent, LetterGrades, average_score); + return 0; +} diff --git a/mod_9b/scores.h b/mod_9b/scores.h new file mode 100644 index 0000000..0f5e872 --- /dev/null +++ b/mod_9b/scores.h @@ -0,0 +1,18 @@ +// +// Created by Till on 27-Oct-21. +// + +#include <iostream> +using namespace std; + +const int NUM_STUDENTS = 10; + +void ReadScores(float[]); //input scores from keyboard +void LetterGrade(char[], float[]); //change score to letter grade and store in alt list +float calcAverage(float[]); //calculate average score for students +void printInfo(float[], char[], float avg); //display all info + + + + + diff --git a/mod_9b/source.cpp b/mod_9b/source.cpp new file mode 100644 index 0000000..366917f --- /dev/null +++ b/mod_9b/source.cpp @@ -0,0 +1,84 @@ +// +// Created by Till on 27-Oct-21. +// +#include "scores.h" + +//creates array of student scores +void ReadScores(float scores[]) +{ + for (int i = 0; i < NUM_STUDENTS; i++) + { + cout << "Enter Score #" << i + 1 << " of " << NUM_STUDENTS << ": " << endl; + cin >> scores[i]; + } +} + +//creates array with list of letter grades for each student +void LetterGrade(char let_grade[], float scores[]) +{ + for (int i = 0; i < NUM_STUDENTS; i++) { + if (scores[i] >= 92.0) { + let_grade[i] = char(65); //A + } else if (scores[i] < 92.0 && scores[i] >= 84.0) { + let_grade[i] = char(66); //B + } else if (scores[i] < 84.0 && scores[i] >= 75.0) { + let_grade[i] = char(67); //C + } else if (scores[i] < 75.0 && scores[i] >= 65.0) { + let_grade[i] = char(68); //D + } else { + let_grade[i] = char(70); //F + } + } +} + + +//Calculate average score +float calcAverage (float scores[]) { + float average = 0.0, total = 0.0; + + for (int i = 0; i < NUM_STUDENTS; i++) { + total += scores[i]; + } + average = total / NUM_STUDENTS; + return average; +} + + +//Displays all info +void printInfo(float scores[], char LetterGrades[],float avg) +{ + int A_grade = 0, B_grade = 0, C_grade = 0, D_grade = 0, F_grade = 0; + + //display score and letter grade for each student + for (int i = 0; i < NUM_STUDENTS; i++) + { + cout << "Student " << i + 1 << " Letter Grade: " << LetterGrades[i]; + cout << " and Score: " << scores[i] << endl; + + } + + // calculate number of each letter grade + for (int i = 0; i < NUM_STUDENTS; i++) { + if (scores[i] >= 92.0) { + A_grade += 1; //A + } else if (scores[i] < 92.0 && scores[i] >= 84.0) { + B_grade += 1; //B + } else if (scores[i] < 84.0 && scores[i] >= 75.0) { + C_grade += 1; //C + } else if (scores[i] < 75.0 && scores[i] >= 65.0) { + D_grade += 1; //D + } else { + F_grade += 1; //F + } + } + + cout << endl; + cout << endl; + cout << "Class Average: " << avg << endl; + + cout << "A's: " << A_grade << endl; + cout << "B's: " << B_grade << endl; + cout << "C's: " << C_grade << endl; + cout << "D's: " << D_grade << endl; + cout << "F's: " << F_grade << endl; +} |