Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that asks a student for his/her grades assessing his/her C++ pro

ID: 3666693 • Letter: W

Question

Write a program that asks a student for his/her grades assessing his/her C++ programming skills. The student gets a separate grade for each homework assignment and the lab exam associated with it. In order for the student to pass the class, he/she needs to achieve 50% or better in all possible “dimensions”, i.e.,

>= 50% average in homework assignments

>= 50% average in lab exams

Assume that the student has been given 5 “sets” of homework assignments and lab exams, respectively, and that the scores are given in percentages.

The program should get input from the screen and do the following:

a) Calculate the best, worst, and average grade for each of the two components (hw assignments and lab exams).

b) Calculate the overall grade of the student, as the average of the hw/lab sets averages.

c) Decide whether the student passes the class or not. If the student cannot pass the class, the program should output the reason why.

d) Output on the screen the input and results so that they look similar to this (use appropriate tools for formatting I/O):

Explanation / Answer

#include <fstream>
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

void get(int data[5])
{
    int i;
    for(i=1;i<=5;i++)
        {
            cout<<"Enter percentage in set "<<i<<" ::";
            cin>>data[i-1];
        }
}

void print(int data[5])
{
    int i;
    for(i=1;i<=5;i++)
        cout<<data[i-1]<<" ";

}

int best(int data[5])
{
    int max = data[0],i;
    for(i=1;i<5;i++)
        if(max<data[i])
            max = data[i];

    return max;
}

int worst(int data[5])
{
    int min = data[0],i;
    for(i=1;i<5;i++)
        if(min>data[i])
            min = data[i];

    return min;
}

float avg(int data[5])
{
    int sum = 0,i;
    for(i=0;i<5;i++)
        sum += data[i];

    return sum/5.0;
}

int main()
{
    int lab[5],hw[5],failed = 0,failed_in,i;
    int average[i];

    printf(" For homework enter percentage for each sets ");
    get(hw);
    printf(" For lab enter percentage for each sets ");
    get(lab);

    cout<<" 1 2 3 4 5"<<endl;

    cout<<" HW ";
    print(hw);
    cout<<"BEST HW: "<<best(hw)<<" WORST HW: "<<worst(hw)<<" AVG HW: "<<avg(hw)<<endl;

    cout<<"LAB ";
    print(lab);
    cout<<"BEST LAB: "<<best(lab)<<" WORST LAB: "<<worst(lab)<<" AVG LAB: "<<avg(lab)<<endl;

    cout<<" AVG ";
    for(i=0;i<5;i++)
        average[i] = (hw[i]+lab[i])/2.0;
    print(average);
    cout<<"OVERALL: "<<avg(average)<<endl;

    if(avg(hw)<50)
        cout<<"I'm sorry to inform you that you failed the class, because your performance in hw was <50%. Try again next semester ";
    else if(avg(lab)<50)
        cout<<"I'm sorry to inform you that you failed the class, because your performance in lab was <50%. Try again next semester ";
    else
        cout<<"Congratulations! You passed the class! ";

    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote