//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CODE FOR PROBLEM #1 (LEARN BY DOING) ON PAGE 253 IS BELOW //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //#include "Header.h" // ////puts scores into array //void GetInput(float currStudent[], int NUM_SCORES) //{ // for (int i = 0; i < NUM_SCORES; i++) // { // cout << "Enter score #" << i + 1 << " of " << NUM_SCORES << ": "; // cin >> currStudent[i]; // } //} // ////translates scores to grades and puts into another array //void ScoreToGrade(float currStudent[], char currStudGradeLTR[], int NUM_SCORES) //{ // for (int i = 0; i < NUM_SCORES; i++) // { // if (currStudent[i] < 65.0) // { // currStudGradeLTR[i] = 'F'; // } // else if (currStudent[i] >= 65.0 && currStudent[i] < 75.0) // { // currStudGradeLTR[i] = 'D'; // } // else if (currStudent[i] >= 75.0 && currStudent[i] < 84.0) // { // currStudGradeLTR[i] = 'C'; // } // else if (currStudent[i] >= 84.0 && currStudent[i] < 92.0) // { // currStudGradeLTR[i] = 'B'; // } // else if (currStudent[i] >= 92.0) // { // currStudGradeLTR[i] = 'A'; // } // } //} // ////finds sum and average of scores //void ScoreAvg(float currStudent[], int NUM_SCORES, float& scoreSum, float& scoreAvg) //{ // scoreSum = 0.0; // scoreAvg = 0.0; // // for (int i = 0; i < NUM_SCORES; i++) // { // scoreSum += currStudent[i]; // } // // scoreAvg = scoreSum / NUM_SCORES; //} // ////counts frequency of different letter grades //void Frequency(char currStudGradeLTR[], int NUM_SCORES, int& freqA, int& freqB, int& freqC, int& freqD, int& freqF) //{ // for (int i = 0; i < NUM_SCORES; i++) // { // if (currStudGradeLTR[i] == 'A') // { // freqA++; // } // if (currStudGradeLTR[i] == 'B') // { // freqB++; // } // if (currStudGradeLTR[i] == 'C') // { // freqC++; // } // if (currStudGradeLTR[i] == 'D') // { // freqD++; // } // if (currStudGradeLTR[i] == 'F') // { // freqF++; // } // } //} // ////displays list of scores with letter grades and class analysis //void Display(float currStudent[], char currStudGradeLTR[], float scoreSum, float scoreAvg, int freqA, int freqB, int freqC, int freqD, int freqF, int NUM_SCORES) //{ // for (int i = 0; i < NUM_SCORES; i++) // { // cout << right << "\n\tScore #" << setw(2) << setfill(char(32)) << i + 1 << ": " // << setw(7) << setfill(char(32)) << left << currStudent[i] << " " << currStudGradeLTR[i]; // } // // cout << "\n========================================================"; // cout << "\n\n\tClass score average: " << scoreAvg; // cout << "\n\n\n\tFrequency of letter grades:"; // cout << "\n\n\t\tA: " << freqA; // cout << "\n\t\tB: " << freqB; // cout << "\n\t\tC: " << freqC; // cout << "\n\t\tD: " << freqD; // cout << "\n\t\tF: " << freqF << "\n\n" << endl; //} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CODE FOR PROBLEM #2 (LEARN BY DOING) ON PAGE 260 IS BELOW //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //#include "Header.h" // ////prompts for first and last name and puts them into arrays //void getInput(char firstName[], char lastName[]) //{ // cout << "\n\n\tEnter first name: "; // cin.getline(firstName, 61); // // cout << "\n\tEnter last name: "; // cin.getline(lastName, 61); //} // ////combines first and last names into another array, adds a comma and space between them //void nameCombine(char firstName[], char lastName[], char fullName[]) //{ // int index = 0; // // for (int i = 0; lastName[i] != '\0'; i++) //puts lastName into fullName // { // fullName[i] = lastName[i]; // } // // for (int i = 0; fullName[i] != '\0'; i++) //counts fullName current length // { // index++; // } // // fullName[index] = ','; //adds comma and space // fullName[index + 1] = ' '; // // for (int i = 0; firstName[i] != '\0'; i++) // { // fullName[i + index + 2] = firstName[i]; // } //} // ////displays full name from array //void display(char firstName[]) //{ // cout << "\n\n===================================================="; // cout << "\n\n\tYour full name is: " << firstName << "\n" << endl; //} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CODE FOR PROBLEM #7 (EXERCISES) ON PAGE 273 IS BELOW //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //#include "Header.h" // ////compares the first 6 characters of the two strings //void compareStrings(char string_1[], char string_2[], int& flag) //{ // for (int i = 0; i <= 5; i++) // { // if (string_1[i] != string_2[i]) // { // flag++; // } // } //}