Starting Out With C++ Chapter 7 Review Answers

The "Affiliate seven – #12: Grade Book – Tony Gaddis – Starting Out With C++" programming challenge comes from Tony Gaddis' volume, "Starting Out with C++ from Control Structures to Objects (eighth Edition)"

Trouble

A teacher has five students who take taken 4 tests. The teacher uses the following grading calibration to assign a letter grade to a student, based on the boilerplate of his or her four test scores.

Test Score Letter Grade
ninety–100 –> A
80–89 –> B
70–79 –> C
lx–69 –> D
0–59 –> F

Write a program that uses an array of string objects to agree the v educatee names, an array of five characters to hold the five students' alphabetic character grades, and v arrays of four doubles to hold each student'south set of test scores.

The program should allow the user to enter each student'southward proper noun and his or her 4 examination scores. It should and then calculate and brandish each student's average test score and a letter grade based on the average.

Input Validation: Do not accept test scores less than 0 or greater than 100.

Solution

            #include <iostream>  using namespace std;  const int NUMBER_OF_TESTS = four; const int NUMBER_OF_STUDENTS = five;  double inputValidate(double); void getStudentTestScores(double[]); double calculateAverageOfArray(const double[], int); char getAverageLetterGrade(double); void getStudentNames(string[]); void getAllTestScores(const string[],                       double[],                       double[],                       double[],                       double[],                       double[]); void calculateAndDisplayAverages(const string[],                                  const double[],                                  const double[],                                  const double[],                                  const double[],                                  const double[]);  int master() {     string studentNames[NUMBER_OF_STUDENTS];      double student1TestScores[NUMBER_OF_TESTS];     double student2TestScores[NUMBER_OF_TESTS];     double student3TestScores[NUMBER_OF_TESTS];     double student4TestScores[NUMBER_OF_TESTS];     double student5TestScores[NUMBER_OF_TESTS];      getStudentNames(studentNames);      getAllTestScores(studentNames,                      student1TestScores,                      student2TestScores,                      student3TestScores,                      student4TestScores,                      student5TestScores);      calculateAndDisplayAverages(studentNames,                                 student1TestScores,                                 student2TestScores,                                 student3TestScores,                                 student4TestScores,                                 student5TestScores);      return 0; } // Stop int principal()  void getStudentNames(cord studentNames[]) {     cout << "Enter student names: " << endl;     for(int i = 0; i < NUMBER_OF_STUDENTS; i++)     {         cout << "Pupil " << (i + i) << " proper name: ";         getline(cin, studentNames[i]); // Jesus Hernandez     } }  void getAllTestScores(const string studentNames[],                       double student1TestScores[],                       double student2TestScores[],                       double student3TestScores[],                       double student4TestScores[],                       double student5TestScores[]) {     cout << "\nEnter exam scores for " << studentNames[0] << endl;     getStudentTestScores(student1TestScores);      cout << "\nEnter test scores for " << studentNames[i] << endl;     getStudentTestScores(student2TestScores);      cout << "\nEnter test scores for " << studentNames[ii] << endl;     getStudentTestScores(student3TestScores);      cout << "\nEnter test scores for " << studentNames[three] << endl;     getStudentTestScores(student4TestScores);      cout << "\nEnter examination scores for " << studentNames[four] << endl;     getStudentTestScores(student5TestScores); }  void getStudentTestScores(double assortment[]) {     for (int i = 0; i < NUMBER_OF_TESTS; i++)     {         cout << "Test #" << (i + one) << ": ";         assortment[i] = inputValidate(array[i]);     } }  double inputValidate(double number) {     while(!(cin >> number) || (number < 0 || number > 100))     {         cout << "Error. A number from 0 thru 100 must be entered: ";         cin.articulate();         cin.ignore(numeric_limits<streamsize>::max(), '\n');     }      return number; }  void calculateAndDisplayAverages(const cord studentNames[],                                  const double student1TestScores[],                                  const double student2TestScores[],                                  const double student3TestScores[],                                  const double student4TestScores[],                                  const double student5TestScores[]) {     // Student #i     double average = calculateAverageOfArray(student1TestScores, NUMBER_OF_TESTS);     cout << "\nAverage test score for " << studentNames[0] << " = " << average << endl;      char average_letter_grade = getAverageLetterGrade(average);     cout << "Alphabetic character grade = " << average_letter_grade << endl;     cout << endl;      // Educatee #2     average = calculateAverageOfArray(student2TestScores, NUMBER_OF_TESTS);     cout << "Average test score for " << studentNames[1] << " = " << boilerplate << endl;      average_letter_grade = getAverageLetterGrade(boilerplate);     cout << "Letter grade = " << average_letter_grade << endl;     cout << endl;      // Student #3     average = calculateAverageOfArray(student3TestScores, NUMBER_OF_TESTS);     cout << "Boilerplate test score for " << studentNames[two] << " = " << average << endl;      average_letter_grade = getAverageLetterGrade(average);     cout << "Letter course = " << average_letter_grade << endl;     cout << endl;      // Student #4     average = calculateAverageOfArray(student4TestScores, NUMBER_OF_TESTS);     cout << "Average exam score for " << studentNames[iii] << " = " << average << endl;      average_letter_grade = getAverageLetterGrade(average);     cout << "Letter grade = " << average_letter_grade << endl;     cout << endl;      // Educatee #five     average = calculateAverageOfArray(student5TestScores, NUMBER_OF_TESTS);     cout << "Average test score for " << studentNames[4] << " = " << average << endl;      average_letter_grade = getAverageLetterGrade(average);     cout << "Letter form = " << average_letter_grade << endl;     cout << endl; }  double calculateAverageOfArray(const double array[], int ARRAY_SIZE) {     double sum = 0;      for (int i = 0; i < ARRAY_SIZE; i++)         sum += assortment[i];      return sum / ARRAY_SIZE; }  char getAverageLetterGrade(double average) {     char letter;      if (average <= 100 && average >= 90)         letter = 'A';     else if (average < xc && average >= 80)         alphabetic character = 'B';     else if (average < 80 && average >= 70)         alphabetic character = 'C';     else if (average < 70 && average >= 60)         letter = 'D';     else if (average < 60 && average >= 0)         letter = 'F';          return letter of the alphabet; }                      

Video Walk Through

This video includes a step by pace process of how to solve "Chapter 7 – #12: Class Book – Tony Gaddis – Starting Out With C++".

Lookout video on YouTube.

Affiliate 7 Playlist on YouTube

That's it for Chapter 7 – #12: Grade Book

Cheers for taking an interest in what I practise! I hope information technology was helpful for yous as much as it helped me along my journeying in learning to code!

C++ Chapter vii Solutions Hither:

Starting Out With C++ | Chapter 7 | Programming Challenge Solutions

Chapter 7 References:

Arrays:http://www.cplusplus.com/md/tutorial/arrays/
Parallel Arrays:https://www.tutorialspoint.com/cplusplus-program-to-implement-parallel-array
Find Smallest Array Value:http://world wide web.cplusplus.com/forum/beginner/66021/
Get Total of Assortment Values:https://world wide web.tutorialspoint.com/assortment-sum-in-cplusplus-stl
Passing an Assortment to a Function:https://www.tutorialspoint.com/cplusplus/cpp_passing_arrays_to_functions.htm
Multidimensional Arrays:https://www.programiz.com/cpp-programming/multidimensional-arrays
Passing Array to a Function:https://www.programiz.com/cpp-programming/passing-arrays-office

Would you consider making a donation?
If and then, here'southward how you tin assist support my page:

Buy Me a Coffee
Become a Patron
Support a Small Business

ezelltorgent.blogspot.com

Source: https://jesushilarioh.com/chapter-7-12-grade-book-tony-gaddis-starting-out-with-c-plus-plus/

0 Response to "Starting Out With C++ Chapter 7 Review Answers"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel