Question

In: Computer Science

Write a program that will find the class average of fifteen (15) test scores for five...

Write a program that will find the class average of fifteen (15) test scores for five (5) different tests. The class average must be stored into an integer array. You are to have three separate arrays: Note: _jd represents the initials of the programmer. Your array and function names should be named by replace the initials jd with your first and last initials Arrays Student Names Scores Averages Name of array students_jd scores_jd averages_jd Size of array [15][10] [15][5] .[5] Data for array Initialized in code Read from data file Calculated and stored Excluding the main function, your program should have three additional functions that will get the scores, calculate the averages and display your output. Functions Read Input File Calculate Average Output Results Name of function get_jd calc_jd prt_jd Properties of function Called from main Called from main Called from main Definition of Function Should pass scores array and add data to array Should pass average array and add averages to array Should pass students, scores and average array and print data Data file should be named da

Solutions

Expert Solution

  • I don't really understand what you wrote in the functions part...like properies of function called from main called from main called from main? If this isn't what you need or something you can't modify into what you're looking for let me know though.

    #include<iostream>

    #include<fstream>

    using namespace std;

    // define the classes

    const int maxStudents = 15;

    const int maxTests = 5;

    void getData(ifstream &dFile, char students_id[15][10], int scores_id[15][5])

    //assuming file looks like this per line, <studentID>< test1> <test2> <test3> <test4>< test5>

    {

    for(int i = 0; i < maxStudents; i++)

    {

    dFile >> students_id[i];

    for(int j = 0; j < maxTests; j++)

    dFile >> scores_id[i][j];

    }

    }

    void calcAvg(int scores_id[15][5], float averages_id[])

    {

    float total;

    for(int i = 0; i < maxStudents; i++)

    {

    total = 0.0;

    for(int j = 0; j < maxTests; j++)

    total += scores_id[i][j];

    averages_id[i] = total / 5.0;

    }

    }

    void printResults(char students_id[15][10], float averages_id[])

    {

    for(int i = 0; i < maxStudents; i++)

    {

    cout << students_id[i] << "'s average: " << averages_id[i] << endl;

    }

    }

    int main()

    {

    char students_id[maxStudents][10];

    int scores_id[maxStudents][5];

    float averages_id[maxStudents];

    ifstream dFile; //variables declared

    if(dFile.good()) dFile.open("data_jd.txt", ios::in); //data file opened for input

    getData(dFile, students_id, scores_id); //fill up arrays with data

    calcAvg(scores_id, averages_id);

    printResults(students_id, averages_id);

    dFile.close(); //closes data file

    system("pause");

    return 0;

    }

    ---
    data file tested with
    student01 51 88 57 91 88
    student02 84 68 70 66 95
    student03 97 61 53 76 76
    student04 79 72 90 54 62
    student05 65 92 75 90 73
    student06 82 56 79 93 70
    student07 72 88 79 50 95
    student08 71 94 62 70 97
    student09 83 73 82 84 65
    student10 100 76 79 73 60
    student11 52 70 50 57 62
    student12 67 84 61 51 74
    student13 94 78 94 86 92
    student14 79 62 98 79 59
    student15 55 77 55 82 84


Related Solutions

Write a program that asks the user to enter five test scores. The program should display...
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Instructions: Write a program to calculate students’ average test scores and their grades. You may assume...
Instructions: Write a program to calculate students’ average test scores and their grades. You may assume the following input data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63...
n-class: Write a program to store exam scores into a file. The program will ask the...
n-class: Write a program to store exam scores into a file. The program will ask the user how many exam scores to enter. Then it will ask the user for each exam score and store them in a file called scores.dat The file output should have the following format . Exam 1: 97 Exam 2: 85 C++ Coding please
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program...
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score. Hint: Declare local variables under main() program Prompts the user to enter 5 test scores Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg Define a function to determine the letter grade: this should accept a test score as argument...
write a program in c++ that asks the user to enter their 5 test scores and...
write a program in c++ that asks the user to enter their 5 test scores and calculates the most appropriate mean. Have the results print to a text file and expected results to print to screen.
Create a program that calculates the average of 3 test scores. Make use of an array...
Create a program that calculates the average of 3 test scores. Make use of an array to store the integer scores. const int size = 3; int testScores[size]; Send this array to a function that actually calculates and returns the average. 1. Tell the user what the program does. 2. Prompt the user to enter the integer scores. ( Use a for loop to do this. ) 3. Create and implement a function with prototype: double average( int a[], int...
Design the logic for a program that has two parts. The user enters 15 test scores...
Design the logic for a program that has two parts. The user enters 15 test scores (values between 1-100) that are stored in an array. The program uses the array to compute and output the following statistics minimum maximum average Write this in pseudocode.
considering a binary class write five-unit test modules to test the class which must include 5...
considering a binary class write five-unit test modules to test the class which must include 5 different solutions
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT