diff options
| author | James Lawrance <[email protected]> | 2021-10-30 09:24:59 -0700 |
|---|---|---|
| committer | James Lawrance <[email protected]> | 2021-10-30 09:24:59 -0700 |
| commit | 0893882a2c5c432bb1ccd17258460a55dae9f08a (patch) | |
| tree | 779b993e163469811044bb2f64ee681160363e25 /CST116F2021-Lab5/CST116F2021-Lab5.cpp | |
| parent | Lab 5 changes night class 10/27 (diff) | |
| download | cst116-lab5-jemersonlawrance-0893882a2c5c432bb1ccd17258460a55dae9f08a.tar.xz cst116-lab5-jemersonlawrance-0893882a2c5c432bb1ccd17258460a55dae9f08a.zip | |
Morning Class Changes 10/30/21 up to 10a
Diffstat (limited to 'CST116F2021-Lab5/CST116F2021-Lab5.cpp')
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.cpp | 240 |
1 files changed, 127 insertions, 113 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp index 27794e9..c1b57ec 100644 --- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp +++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp @@ -1,6 +1,4 @@ -#include <iostream> -using namespace std; - +#include "CST116F2021-Lab5(Header).h" //9a - //Section 10.5 - @@ -97,126 +95,142 @@ using namespace std; //Section 10.6 //Function Prototypes -void getScores(int studentScores[]); -void calculateGrades(int studentScores[], char studentGrades[]); -void displayGrades(char studentGrades[]); -void classAverage(int studentScores[]); -void studentsPerGrade(char studentGrades[]); +//void getScores(int studentScores[]); +//void calculateGrades(int studentScores[], char studentGrades[]); +//void displayGrades(char studentGrades[]); +//void classAverage(int studentScores[]); +//void studentsPerGrade(char studentGrades[]); -int main() -{ +//int main() +//{ //defining - int studentScores[10]; - char studentGrades[10]; +// int studentScores[10]; +// char studentGrades[10]; //entry sequence - cout << "Welcome to the 10 scores to grades program." << endl; +// cout << "Welcome to the 10 scores to grades program." << endl; //get scores - cout << endl; - getScores(studentScores); +// cout << endl; +// getScores(studentScores); //calculate grades - calculateGrades(studentScores, studentGrades); +// calculateGrades(studentScores, studentGrades); //display grades - cout << endl; - displayGrades(studentGrades); +// cout << endl; +// displayGrades(studentGrades); //display class average - cout << endl; - classAverage(studentScores); +// cout << endl; +// classAverage(studentScores); //display students per grade - cout << endl; - studentsPerGrade(studentGrades); +// cout << endl; +// studentsPerGrade(studentGrades); - return 0; -} +// return 0; +//} -void getScores(int studentScores[]) -{ - for (int scoreCount = 0; scoreCount < 10; scoreCount++) - { - cout << "Please enter student " << scoreCount + 1 << "'s score: "; - cin >> studentScores[scoreCount]; - } -} - -void calculateGrades(int studentScores[], char studentGrades[]) -{ - for (int scoreCount = 0; scoreCount < 10; scoreCount++) - { - if (studentScores[scoreCount] >= 92.0) - { - studentGrades[scoreCount] = 'A'; - } - else if (studentScores[scoreCount] >= 84.0) - { - studentGrades[scoreCount] = 'B'; - } - else if (studentScores[scoreCount] >= 75.0) - { - studentGrades[scoreCount] = 'C'; - } - else if (studentScores[scoreCount] >= 65.0) - { - studentGrades[scoreCount] = 'D'; - } - else if (studentScores[scoreCount] < 65.0) - { - studentGrades[scoreCount] = 'F'; - } - } -} - -void displayGrades(char studentGrades[]) -{ - for (int gradeCount = 0; gradeCount < 10; gradeCount++) - { - cout << "Student " << gradeCount + 1 << "'s final grade: " << studentGrades[gradeCount] << endl; - } -} +//void getScores(int studentScores[]) +//{ +// for (int scoreCount = 0; scoreCount < 10; scoreCount++) +// { +// cout << "Please enter student " << scoreCount + 1 << "'s score: "; +// cin >> studentScores[scoreCount]; +// } +//} -void classAverage(int studentScores[]) -{ - float classAverage = 0; - for (int scoreCount = 0; scoreCount < 10; scoreCount++) - { - classAverage = classAverage + studentScores[scoreCount]; - } - cout << "Class average: " << classAverage / 10 << endl; -} - -void studentsPerGrade(char studentGrades[]) +//void calculateGrades(int studentScores[], char studentGrades[]) +//{ +// for (int scoreCount = 0; scoreCount < 10; scoreCount++) +// { +// if (studentScores[scoreCount] >= 92.0) +// { +// studentGrades[scoreCount] = 'A'; +// } +// else if (studentScores[scoreCount] >= 84.0) +// { +// studentGrades[scoreCount] = 'B'; +// } +// else if (studentScores[scoreCount] >= 75.0) +// { +// studentGrades[scoreCount] = 'C'; +// } +// else if (studentScores[scoreCount] >= 65.0) +// { +// studentGrades[scoreCount] = 'D'; +// } +// else if (studentScores[scoreCount] < 65.0) +// { +// studentGrades[scoreCount] = 'F'; +// } +// } +//} + +//void displayGrades(char studentGrades[]) +//{ +// for (int gradeCount = 0; gradeCount < 10; gradeCount++) +// { +// cout << "Student " << gradeCount + 1 << "'s final grade: " << studentGrades[gradeCount] << endl; +// } +//} + +//void classAverage(int studentScores[]) +//{ +// float classAverage = 0; +// for (int scoreCount = 0; scoreCount < 10; scoreCount++) +// { +// classAverage = classAverage + studentScores[scoreCount]; +// } +// cout << "Class average: " << classAverage / 10 << endl; +//} + +//void studentsPerGrade(char studentGrades[]) +//{ +// int studentAs = 0; +// int studentBs = 0; +// int studentCs = 0; +// int studentDs = 0; +// int studentFs = 0; + +// for (int gradeCount = 0; gradeCount < 10; gradeCount++) +// { +// if (studentGrades[gradeCount] == 'A') +// { +// studentAs++; +// } +// if (studentGrades[gradeCount] == 'B') +// { +// studentBs++; +// } +// if (studentGrades[gradeCount] == 'C') +// { +// studentCs++; +// } +// if (studentGrades[gradeCount] == 'D') +// { +// studentDs++; +// } +// if (studentGrades[gradeCount] == 'F') +// { +// studentFs++; +// } +// } + +// cout << studentAs << " students got A's" << endl; +// cout << studentBs << " students got B's" << endl; +// cout << studentCs << " students got C's" << endl; +// cout << studentDs << " students got D's" << endl; +// cout << studentFs << " students got F's" << endl; +//} + +//10a +//9.4 Learn by Doing Exercises (this problem will be broken into 3 files) + +int main() { - int studentAs = 0; - int studentBs = 0; - int studentCs = 0; - int studentDs = 0; - int studentFs = 0; - - for (int gradeCount = 0; gradeCount < 10; gradeCount++) - { - if (studentGrades[gradeCount] == 'A') - { - studentAs++; - } - if (studentGrades[gradeCount] == 'B') - { - studentBs++; - } - if (studentGrades[gradeCount] == 'C') - { - studentCs++; - } - if (studentGrades[gradeCount] == 'D') - { - studentDs++; - } - if (studentGrades[gradeCount] == 'F') - { - studentFs++; - } - } - - cout << studentAs << " students got A's" << endl; - cout << studentBs << " students got B's" << endl; - cout << studentCs << " students got C's" << endl; - cout << studentDs << " students got D's" << endl; - cout << studentFs << " students got F's" << endl; + //defining arrays + char firstName[15] = {}; + char lastName[15] = {}; + //get firstName and lastName (call function getName) + getName(firstName, lastName); + //format full name (call function formatName) + formatName(firstName, lastName); + + return 0; }
\ No newline at end of file |