diff options
| author | austinsworld15 <[email protected]> | 2021-11-02 16:51:13 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-02 16:51:13 -0700 |
| commit | 30976724c27b662c24ecf635dff64bf5cc3c1076 (patch) | |
| tree | ea7d8c0000029190f6930a4799403673fd7ced44 | |
| parent | Update CST116F2021-Lab5.cpp (diff) | |
| download | cst116-lab5-austinsworld15-30976724c27b662c24ecf635dff64bf5cc3c1076.tar.xz cst116-lab5-austinsworld15-30976724c27b662c24ecf635dff64bf5cc3c1076.zip | |
Update CST116F2021-Lab5.cpp
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.cpp | 216 |
1 files changed, 92 insertions, 124 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp index 2c18946..0e577ba 100644 --- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp +++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp @@ -108,180 +108,148 @@ int main() cout << "\nNumber of F's is/are: " << fCount << " \n\n"; } - - 9b 10.6 pg 253 #1 1. - - - - -10a 9.4 pg 214 #2 - -2. - Voids.h #ifndef VOIDS_H #define VOIDS_H -void GetInput(float& salary, int& years_service); -void CalcRaise(float& salary, int& years_service); -int CalcBonus(int years_service); -void PrintCalculations(int years_service, float salary, int bonus); +void GetInput(int scores[]); +void CalculateLetterGrade(int scores[], char grades[]); +void CalculateAverageAndLetterCount(double& avg, int scores[], char grades[], int& aCount, int& bCount, int& cCount, int& dCount, int& fCount); +void DisplayInformation(double& avg, int scores[], char grades[], int& aCount, int& bCount, int& cCount, int& dCount, int& fCount); #endif Functions.cpp -#include "voids.h" +#include "Voids.h" #include <iostream> using namespace::std; -void GetInput(float& salary, int& years_service) +void GetInput(int scores[]) { - cout << "Enter employee's salary: "; - std::cin >> salary; - if (salary > 0) + cout << "Enter numeric grades separated by spaces:"; + + for (int i = 0; i < 10; i++) { - cout << "enter the employee's years of service: "; - std::cin >> years_service; + cin >> scores[i]; } } -void CalcRaise(float& salary, int& years_service) + +void CalculateLetterGrade(int scores[], char grades[]) { - if (years_service > 10) - { - cout << "10% will raise\n"; - } - else if (years_service > 5) - { - cout << "5% will raise\n"; - } - else + for (int i = 0; i < 10; i++) + { - cout << "2% will raise\n"; - } -} -int CalcBonus(int years_service) -{ - int calculate_bonus = 500 * (int)(years_service / 2); - return calculate_bonus; -} -void PrintCalculations(int years_service, float salary, int bonus) -{ - cout << "Your total years of service is " << years_service << endl; - cout << "Your salary is " << salary << endl; - cout << "Your total bonus is " << bonus << endl; -} + if (scores[i] >= 92) -Main.cpp + grades[i] = 'A'; -#include "voids.h" + else if (scores[i] >= 84) -int main(void) -{ - float salary = 0; - int years_service = 0; + grades[i] = 'B'; + + else if (scores[i] >= 75) + + grades[i] = 'C'; + + else if (scores[i] >= 65) - GetInput(salary, years_service); - CalcRaise(salary, years_service); - PrintCalculations(years_service, salary, CalcBonus(years_service)); - return 0; + grades[i] = 'D'; + + else + + grades[i] = 'F'; + } } -10b 9.5 pg 216 #7 +void CalculateAverageAndLetterCount(double& avg, int scores[], char grades[], int& aCount, int& bCount, int& cCount, int& dCount, int& fCount) +{ + for (int i = 0; i < 10; i++) -7. + { + avg += scores[i]; -Voids.h + if (grades[i] == 'A') -#ifndef VOIDS_H -#define VOIDS_H + aCount++; -void GetInput(int& hours, int& minutes, int& seconds, char& style); -void PrintTime(int hours, int minutes, int seconds, char style); + else if (grades[i] == 'B') -#endif + bCount++; -Functions.cpp + else if (grades[i] == 'C') -#include "Voids.h" + cCount++; -#include <iostream> + else if (grades[i] == 'D') -using namespace::std; + dCount++; -void GetInput(int& hours, int& minutes, int& seconds, char& style) -{ - cout << "Input the hour as of right now: "; - cin >> hours; - cout << "\nInput the minutes as of right now: "; - cin >> minutes; - cout << "\nInput the seconds as of right now: "; - cin >> seconds; - cout << "\nIs the time am or pm time? ('a' for am and 'p' for pm): "; - cin >> style; + else + + fCount++; + } + + avg = avg / 10; } -void PrintTime(int hours, int minutes, int seconds, char style) + +void DisplayInformation(double& avg, int scores[], char grades[], int& aCount, int& bCount, int& cCount, int& dCount, int& fCount) { - if (style == 'a') - { - cout << "\n\nIf you want the time in standard notation, the time is " << hours << ":" << minutes << ":" << seconds << "\n" << endl; - cout << "\nAnd if you want the time in Military time, the time is " << hours << ":" << minutes << ":" << seconds << "\n" << endl; - } - else if (style == 'p') + for (int i = 0; i < 10; i++) + { - cout << "\n\nIf you want the time in standard notation, the time is " << hours << ":" << minutes << ":" << seconds << "\n" << endl; - cout << "\nAnd if you want the time in Military time, the time is " << hours + 12 << ":" << minutes << ":" << seconds << "\n" << endl; + cout << "Score " << (i + 1) << ": " << scores[i] << ", and the grade is a(n) " << grades[i] << endl; } -} -Main 10b 9.5 pg 216 number 7 - -#include <iostream> + cout << "\nAverage of all the scores is: " << avg << " \n\n"; + + cout << "\nNumber of A's is/are: " << aCount << " \n"; + + cout << "\nNumber of B's is/are: " << bCount << " \n"; + + cout << "\nNumber of C's is/are: " << cCount << " \n"; + + cout << "\nNumber of D's is/are: " << dCount << " \n"; + + cout << "\nNumber of F's is/are: " << fCount << " \n\n"; +} +Main 9b 10.6 pg 253 number 1 + #include "Voids.h" -int main(void) +int main() { - using namespace::std; + int scores[10]; + char grades[10]; + double avg = 0; + int aCount = 0; + int bCount = 0; + int cCount = 0; + int dCount = 0; + int fCount = 0; - int hours = 0; - int minutes = 0; - int seconds = 0; - char style; + GetInput(scores); + CalculateLetterGrade(scores, grades); + CalculateAverageAndLetterCount(avg, scores, grades, aCount, bCount, cCount, dCount, fCount); + DisplayInformation(avg, scores, grades, aCount, bCount, cCount, dCount, fCount); +} + +10a 10.7 pg 260 #2 + +2. + + + +10b 10.8 pg 273 #7 + +7. - GetInput(hours, minutes, seconds, style); - if (hours > 12 || hours < 0) - { - cout << "\n\nYou cannot have more than 24 hours in a day, run the program again\n\n"; - return 0; - } - if (minutes < 0 || minutes >= 60) - { - cout << "\n\nYou cannot have more than 60 minutes in an hour, run the program again\n\n"; - return 0; - } - if (seconds < 0 || seconds >= 60) - { - cout << "\n\nYou cannot have more than 60 seconds in a minute, run the program again\n\n"; - return 0; - } - if (style == 'a' || style == 'p') - { - cout << "\n\nCalculating the time\n\n"; - } - else - { - cout << "\n\nYou did not input the specified letters, run the program and try again.\n\n"; - return 0; - } - PrintTime(hours, minutes, seconds, style); - return 0; -} |