Question

In: Computer Science

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 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

Program code:

#include<iostream>
using namespace std;

int Score[12];     //Array to store scores of 12 students.
char grade[12];     //Array to store grades of 12 students.
int minScore,maxScore; //Variables to store Minimum and maximum scores
float sum,average;         //Variables to store sum and average of 12 scores.
string Subject;          //Variable to store Subject name.

void Prompt(int Score[12])   //Function to input scores of 12 students.
{
    int val;
    cout << "Enter Subject Name:";
    cin >> Subject;
    cout << "Enter marks:" << endl;
    for(int i=0;i<12;i++)
    {
        cout << "Student - " << i+1 << " Score :";
        cin >> val;
        if(val>=0 && val<=100)
            Score[i]=val;
        else
        {
           cout << "Score should be between 0-100." <<endl;
           i=i-1;
        }
    }
}

void MinMax(int Score[12])   //Function to find minimum and maximum score
{
    minScore=Score[0],maxScore=Score[0];
    for(int i=1;i<12;i++)
    {
        if(minScore>Score[i])
            minScore=Score[i];
        if(maxScore<Score[i])
            maxScore=Score[i];
    }
    cout << "Maximum score is :"<< maxScore << endl << endl;
    cout << "Minimum score is :"<< minScore << endl << endl;
}

void Average(int Score[12])   //Function to find average of 12 scores
{
    sum=0;
    for(int i=0;i<12;i++)
    {
        sum=sum+Score[i];
    }
    average=sum/12;
    cout << "Average score is: " << average << endl << endl;
}

void Passed(int Score[12])   //Function to find the number of students passed and failed.
{
    int pass=0;//fail;
    for(int i=0;i<12;i++)
    {
        if(Score[i]>60)
            pass++;
    }
    //fail=12-pass;
    cout << "Number of students passed:"<< pass <<endl<<endl;
    cout << "Number of students failed:"<< (12-pass) <<endl<<endl;
}

void Grade(int Score[12])   //Function to find grades of students
{
    for(int i=0;i<12;i++)
    {
        if(Score[i]>=90)
            grade[i]='A';
        else if(Score[i]>=80 && Score[i]<90)
            grade[i]='B';
        else if(Score[i]>=70 && Score[i]<80)
            grade[i]='C';
        else if(Score[i]>=60 && Score[i]<70)
            grade[i]='D';
        else
            grade[i]='F';
    }
    cout << "Grades of students is :"<<endl;
    for(int i=0;i<12;i++)
        cout << grade[i] << " ";
}

void display()    //Function to print all those values
{
    cout << endl << "Exam Name:" << Subject << endl << endl;
    cout << "Scores of students are:" << endl;
    for(int i=0;i<12;i++)
        cout << Score[i] << " ";
    cout << endl << endl;
    Average(Score);
    MinMax(Score);
    Passed(Score);
    Grade(Score);
}

int main()
{
    Prompt(Score);
    display();
}


Output:


Related Solutions

1.Write a C++ program using control structures, arrays, functions to calculate the number of dollars, quarters,...
1.Write a C++ program using control structures, arrays, functions to calculate the number of dollars, quarters, dimes, nickels, and pennies in a given amount of money. The input should be a floating-point value representing a decimal value. Example: 63.87 à 63 [dollars and 87 cents] should output 63 dollars, 3 quarters, 1 dime, 0 nickels, and 2 pennies. 2. In trigonometry the cosine function can be calculated using cos(x) = 1 – x 2 /2! + x 4 /4!- x...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three...
C++ DO not use arrays to write this program. Write a program that repeatedly generates three random integers in the range [1, 100] and continues as follows: If the right-most digit of all the three integers is equal, the program displays them in ascending order on the screen and continues. If the generated integers have different right-most digits, they are not displayed and the program continues. The program terminates once the right-most digits of all the three random numbers are...
Write a procedure to calculate Average of numbers(integers) using Arrays. Send base address of array in...
Write a procedure to calculate Average of numbers(integers) using Arrays. Send base address of array in register $a1 and Array length in register $a2 to the procedure and return Average in register $v0 to main program.
Using Dev-C++ write a program that allows a small business owner to input, in parallel arrays,...
Using Dev-C++ write a program that allows a small business owner to input, in parallel arrays, the type of item, its cost, and the number in stock. The program should output this information in the form of a table. The output will look something like below. Also, assume for a finite number of item name of 3 Item Name Cost Number in Stock Widget 25.00 4 ... ... ... Wombet 47.50 9 Prelude to Programming (6th edition)
Write C program Multidimensional Arrays Design a program which uses two two-dimensional arrays as follows: an...
Write C program Multidimensional Arrays Design a program which uses two two-dimensional arrays as follows: an array which can store up to 50 student names where a name is up to 25 characters long an array which can store marks for 5 courses for up to 50 students The program should first obtain student names and their corresponding marks for a requested number of students from the user. Please note that the program should reject any number of students that...
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...
Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation...
Write a C++ program to do the following USING ARRAYS 1) input 15 integers (input validation , all numbers must be between 0 and 100) 2) find the largest number 3) Find the Smallest Number 4) Find the Sum of all numbers in the Array Display: as per the user's section (menu using switch or if else ) Largest Number Smallest Number Sum of all numbers the original Array DO NOT USE METHODS OR FUNCTIONS Submit: Source code (C++) output...
using c++ 10. Sorting Orders Write a program that uses two identical arrays of eight integers....
using c++ 10. Sorting Orders Write a program that uses two identical arrays of eight integers. It should display the contents of the first array, then call a function to sort it using an ascending order bubble sort, modified to print out the array contents after each pass of the sort. Next the program should display the contents of the second array, then call a function to sort it using an ascending order selection sort, modified to print out the...
IN C++ Write a program that uses nested loops to collect data and calculate the average...
IN C++ Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask the user for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the ­­program should display 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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT