Question

In: Computer Science

(Write a program in C++) A local instructor wants you to write a program to calculate...

(Write a program in C++)

A local instructor wants you to write a program to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above is considered passing. Also determine the number of scores that were an A (90 or better), B (80 – 89), C (70 – 79), D (60 – 69), or F (below 60).

• Use main( ) as the driver function. Allow the user to process as many exams as desired.

1. Write a function to prompt the user for the following information:

(a) The name of the exam.

(b) The 12 integer scores ranging from 0 to 100. (Store these scores in a one-dimensional array.

Perform input/data validation.)

2. Write a function to determine the highest and lowest score. (Hint: Code is in your etext section:

Finding the Highest and Lowest Values in a Numeric Array)

3. book or see assignment #1.)

4. Write a function to calculate the average score for the exam. (Hint: Code is in your etext section:

Finding the Highest and Lowest Values in a Numeric Array)

5. Write a function to determine the number of students who passed and failed the exam.

6. Write a function to determine the number of scores represented by each letter grade in a standard 10-

point grading scale.

7. Write a function to display the exam’s name, all 12 scores recorded on the exam, the average score,

the highest and lowest score, the number of students who passed and failed the exam, and number of scores that were represented by each letter grade in the standard 10-point grading scale. Display the average to a hundredth of a decimal.

Solutions

Expert Solution

#include <iostream>
#include <string>
using namespace std;
class students{
public:
    string examName;
    int scores[12];
    void getDetails(){
    cout<<"Enter the ExamName:";
    cin>>examName;
    cout<<"Enter the scores of each student\n";
    for(int i=0;i<12;i++){
        cout<<"Enter the score of student "<<(i+1)<<": ";
        cin>>scores[i];
    }
    }
    int* highAndLow(){
        int min=scores[0];
        int max=scores[0];
        cout<<"highAndLow";
        for(int i=0;i<12;i++){
            if(min>scores[i]){
                min=scores[i];
            }
            if(max<scores[i]){
                max=scores[i];
            }
        }
        int* a[]=new int[2];
        a[0]=min;
        a[1]=max;
        return a;
    }
    double avgScore(){
        double avg=0;
        cout<<"avgScore";
        for(int i=0;i<12;i++){
            avg=avg+scores[i];
        }
        avg=avg/12;
        return avg;
    }
    int* passAndFail(){
        int pass=0;
        int fail=0;
        cout<<"passAndFail";
        for(int i=0;i<12;i++){
            if(scores[i]>=60){
                pass=pass+1;
            }
            else{
                fail=fail+1;
            }
        }
        int* arr[]=new int[2];
        arr[0]=pass;
        arr[1]=fail;
        return arr;
    }
    int* noOfScoresGrading(){
        int A=0,B=0,C=0,D=0,F=0;
        cout<<"noOfScoresGrading";
        for(int i=0;i<12;i++){
            int n=scores[i];
            if(n>=90){A++;}
            else if(n>=80&&n<=89){B++;}
            else if(n>=70&&n<=79){C++;}
            else if(n>=60&&n<=69){D++;}
            else{F++;}
        }
        int* arr[]=new int[5];
        arr[0]=A;
        arr[1]=B;
        arr[2]=C;
        arr[3]=D;
        arr[4]=F
        return arr;
    }
    void display(){
        int a[]=highAndLow();
        int b=avgScore();
        int p[]=passAndFail();
        int g[]=noOfScoresGrading();
        cout<<"Examname:"<<examName;
        cout<<"\nScores of each student is:";
        for(int i=0;i<12;i++){
            cout<<"\nStudent "<<(i+1)<<" Score:"<<scores[i];
        }
        cout<<"\nThe highest score is:"a[1];
        cout<<"\nThe lowest score is:"+a[0];
        cout<<"\nThe number of students who passed:"+p[0];
        cout<<"\nThe number of students who failed:"+p[1];
        cout<<"\nThe average score is:"<<b;
        cout<<"\nNumber of students of Grade:A is:"+g[0];
        cout<<"\nNumber of students of Grade:B is:"+g[1];
        cout<<"\nNumber of students of Grade:C is:"+g[2];
        cout<<"\nNumber of students of Grade:D is:"+g[3];
        cout<<"\nNumber of students of Grade:F is:"+g[4];
    }
};
int main()
{ 
    students s;
    s.getDetails();
    s.highAndLow();
    s.avgScore();
    s.passAndFail();
    s.noOfScoresGrading();
    s.display();
    return 0;
}

Thank you! if you have any queries post it below in the comment section I will try my best to resolve your queries and I will add it to my answer if required. Please give upvote if you like it.


Related Solutions

A local instructor wants you to write a c++ program using arrays to calculate the average...
A local instructor wants you to write a c++ program using arrays to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above...
C++ program: ABC Co wants you to develop a C++ program to calculate the total invoice...
C++ program: ABC Co wants you to develop a C++ program to calculate the total invoice based on the user inputs item price and the quantity of the item purchased, taking into consideration the discount given for each category as follow: Less than 10 Item: No discount Between 10 and 20 items: 10 % off the item price More than 20 items: 20% off the item price. Your Program should display, the total before discount, how much discount and the...
The local taqueria wants you to write a program which tracks the number of burritos they...
The local taqueria wants you to write a program which tracks the number of burritos they sell each day and help them analyze their business. Your C++ program should ask the user for the number of different burrito types sold, then get the names of the types and the number of burritos sold of each type of that day. Print out a daily report listing sales for each burrito type and total number of all burritos sold. So far, this...
The local taqueria wants you to write a program which tracks the number of burritos they...
The local taqueria wants you to write a program which tracks the number of burritos they sell each day and help them analyze their business. The C++ program should ask the user for the number of different burrito types sold, then get the names of the types and the number of burritos sold of each type of that day. It asks to print out a daily report listing sales for each burrito type and total number of all burritos sold....
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
C++ Program: Write another program (in C++) that will allocate a local static array of integers...
C++ Program: Write another program (in C++) that will allocate a local static array of integers and then a dynamic array of integers. Are they stored next to each other? You can examine this by examining the memory addresses where they are located. As described in class, on some systems the size of a dynamic array is actually stored in the bytes previous to a dynamically allocated array. Through some experiments on your own, try to see if this is...
Write a program in C++ that solves this problem Calculate the area and volume of a...
Write a program in C++ that solves this problem Calculate the area and volume of a sphere problem. Inside a for loop, vary the radius from 10 to 40  with a step or increment of 5 and calculate the area and volume Your radius will be equal to your loop counter. All calculations should have 2 decimal places, but the radius should have zero decimal places and any number of 1,000 or more should have a comma. Print the radius, area,...
Write a C++ program: The local taqueria has decided they need to raise their prices. In...
Write a C++ program: The local taqueria has decided they need to raise their prices. In order to soften the blow to their customers, they also want to rename all their burritos to make them sound more desirable. Your program should create two arrays in main() - one string array with 3 burrito types and one float array with 3 associated prices, defined below: string names[] = {"Carnitas", "Pollo", "Veggie"}; float prices[] = {6.95, 6.25, 5.95}; Now, main should declare...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT