Question

C++ Use C++ functions and build a program that does the most basic job all students...

C++

Use C++ functions and build a program that does the most basic job all students have to contend with, process the grades on a test and produce a summary of the results. The big wrinkle is, it should be a multi-file program.

-Requires three simple things:

  • Figure out the best score of all scores produced
  • Figure out the worst score of all scores produced
  • Assign a letter grade for each score produced
  • Complete this lab by writing three functions.
  • Here is our list of grades to process:
  • int grades[15] = { 55, 87, 93, 77, 92, 88, 67, 81, 84, 73, 81, 92, 89, 100, 62 };
  • Call each function with the grades array as a parameter, and the number of         values in that array in your main routine and make it do the following work:
  • Use the max value function to print out the max value found in the grade array.
  • Use the min value function to print out the min value found in the grade array
  • Use the letter grade function to print out the grade number and the associated letter grade for each score in the array. This will require a nested if-then-else statement to figure this out.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is your code: -

gradeHelper.cpp

#include<iostream>
using namespace std;

int maxValue(int grades[], int size) {
   int max = 0;
   for(int i = 0;i < size; i++) {
       if(max < grades[i]) {
           max = grades[i];
       }
   }
   return max;
}

int minValue(int grades[], int size) {
   int min = grades[0];
   for(int i = 0;i < size; i++) {
       if(min > grades[i]) {
           min = grades[i];
       }
   }
   return min;
}

char getLetterGrade(int grade_num) {
   char letter;
   if (grade_num<=60) {
   letter = 'F';
}
else if ( grade_num<=69) {
letter = 'D';
}
else if (grade_num<=79) {
letter = 'C';
}
else if (grade_num<=89) {
letter = 'B';
}
else if(grade_num<=100) {
   letter = 'A';  
   }
return letter;
}

gradeTester.cpp

#include<iostream>
#include "gradeHelper.cpp"

int main() {
   int grades[15] = { 55, 87, 93, 77, 92, 88, 67, 81, 84, 73, 81, 92, 89, 100, 62 };
  
   int max = maxValue(grades,15);
   int min = minValue(grades,15);
  
   cout<<"Grades entered: ";
   for(int i = 0; i< 15; i++) {
       cout<<grades[i]<<" ";
   }
  
   cout<<"\n\nMaximum Score: "<<max<<endl;
   cout<<"Minimum Score: "<<min<<endl;
  
   cout<<"\nGrades Summary: "<<endl;
   cout<<"\nScore\t\tGrade"<<endl;
   for(int i = 0; i< 15; i++) {
       cout<<grades[i]<<"\t\t"<<getLetterGrade(grades[i])<<endl;
   }
}

Output

Grades entered: 55 87 93 77 92 88 67 81 84 73 81 92 89 100 62

Maximum Score: 100
Minimum Score: 55

Grades Summary:

Score Grade
55 F
87 B
93 A
77 C
92 A
88 B
67 D
81 B
84 B
73 C
81 B
92 A
89 B
100 A
62 D

Add a comment
Know the answer?
Add Answer to:
C++ Use C++ functions and build a program that does the most basic job all students...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes...

    SOLVE IN PYTHON:Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array....

  • In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a tes...

    In C++ Assignment 8 - Test Scores Be sure to read through Chapter 10 before starting this assignment. Your job is to write a program to process test scores for a class. Input Data You will input a test grade (integer value) for each student in a class. Validation Tests are graded on a 100 point scale with a 5 point bonus question. So a valid grade should be 0 through 105, inclusive. Processing Your program should work for any...

  • C++ Single Dimensional Arrays

    Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array.  The program...

  • 1. Create a program that takes a numerical score and outputs a letter grade. 2. In...

    1. Create a program that takes a numerical score and outputs a letter grade. 2. In this program, create two void functions titled makeScore and theGrade with an int argument. 3. The function makeScore should have a Reference parameter and theGrade should have a Value parameter. Note: Specific numerical scores and letter grades are listed below: 90-100 = Grade A 80-89 = Grade B 70-79 = Grade C 60-69 = Grade D 0-59 = Grade F 4. The function makeScore...

  • In Java Main method Your main program will prompt the user for a test name and...

    In Java Main method Your main program will prompt the user for a test name and the number of scores the user will enter. After creating an arraylist to hold the scores, prompt the user for all the scores to hold in the arraylist. After all the scores are entered, then repeat back the score & letter grade. GradeBook Object Create an instance of a GradeBook object and pass the test name and arraylist to set the instance variables. At...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • Create a C++ program to : Prompt user for seven test score Store the scores into...

    Create a C++ program to : Prompt user for seven test score Store the scores into an array Print the array before and after sorting Print the test average Convert the average to letter grade Search for a test score 90, using linear search Print, if test score 90 was found and at what position Add Comments SEPARATE THE FILES INTO 3 : header.h, functions.cpp, main.cpp

  • C++ Write a program to calculate final grade in this class, for the scores given below...

    C++ Write a program to calculate final grade in this class, for the scores given below . Remember to exclude one lowest quiz score out of the 4 while initializing the array. Display final numeric score and letter grade. Use standard include <iostream> Implementation: Use arrays for quizzes, labs, projects and exams. Follow Sample Output for formatting. May use initialization lists for arrays. Weight distribution is as follows: Labs: 15% Projects: 20% Quizzes: 20% Exams: 25% Final Project: 20% Display...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT