Question

In: Computer Science

In C++, Mrs. Jones wishes to computerize her grading system. She gives 5 tests but only...

  1. In C++, Mrs. Jones wishes to computerize her grading system. She gives 5 tests but only counts the 4 highest scores. Input the 5 test scores and output the average of the highest four. And using the following grading scale, 90-100 A, 80-89 B, 70-79 C, 60-69 D, and below 60 F, output the student’s letter grade. After creating this code, Modify the above to calculate the grade for all students in the class. The first input value will be the number of students in the class. You will then need to use a loop to input the students’ names as well as their 5 grades. Inside the loop (after calculating the average for the student) you will need to add each student’s average to a sum variable because at the end, you will need to print out the class average as well as each students’ names and letter grades.

Solutions

Expert Solution

Part 1:

#include<bits/stdc++.h>
using namespace std;
int main(){
    int sum=0,min=999;
    int marks[5];
    char grade;
    for(int i=0;i<5;i++){
        cout<<"Marks of Test "<<i+1<<": "<<endl;
        cin>>marks[i];
        if(min>marks[i]){
            min=marks[i];
        }
        sum+=marks[i];
    }
    double average=(sum-min)/4;
    if(average<60)
        grade='F';
    else if(average<70)
        grade='D';
    else if(average<80)
        grade='C';
    else if(average<90)
        grade='B';
    else if(average<=100)
        grade='A';
    cout<<"Average of highest four is : "<<average<<endl;
    cout<<"Grade Obtained: "<<grade<<endl;
}

Output:

2.

#include<bits/stdc++.h>
using namespace std;
double classSum;
class Student{
    public: 
        string name,grade;
        int marks[5],min=999,sum=0;
        double average;
        
        void input(){
            cout<<"\n";
            for(int i=0;i<5;i++){
                cout<<"Marks in Test "<<i+1<<": "<<endl;
                cin>>marks[i];
                sum+=marks[i];
                if(min>marks[i]){
                    min=marks[i];
                }
            }
        }
        void calAvgOf(){
            average=(sum-min)/4;
            classSum+=average;
            
        }
        
        string gradeObtained(){
            if(average<60)
                grade='F';
            else if(average<70)
                grade='D';
            else if(average<80)
                grade='C';
            else if(average<90)
                grade='B';
            else if(average<=100)
                grade='A';
            return grade;
        }
        void display(){
            cout<<name<<" "<<grade<<endl;
        }

};
int main(){
    int numStudent;
    cout<<"Enter the number of Student in class:"<<endl;
    cin>>numStudent;
    Student s[numStudent];
    for(int i=0;i<numStudent;i++){
        cout<<"Name of the student: ";
        cin>>s[i].name;
        cout<<"Enter the "<<s[i].name<<" marks: ";
        s[i].input();
        s[i].calAvgOf();
        s[i].gradeObtained();
        cout<<"------------------------------------------------------------------------------\n";
    }
    cout<<"**********************************************************\n";
    cout<<"Class Average: "<<classSum/numStudent<<endl;
    for(int i=0;i<numStudent;i++){
        cout<<i+1<<". ";
       s[i].display();
    }
       
}

Output:


Related Solutions

Mrs. Jones is seeking a divorce from Mr. Jones. Under the terms of her prenuptial agreement,...
Mrs. Jones is seeking a divorce from Mr. Jones. Under the terms of her prenuptial agreement, her settlement will be $100,000 if she can prove that Mr. Jones has had an affair, but $50,000 otherwise. Her lawyer, acting as her agent, can prove the affair only if he hires a private detective for $10,000, which will come out of the lawyer's fee. Mrs. Jones has the option of paying her lawyer a flat fee of $20,000 regardless of the outcome...
C++ Chapter 4/5 Lab Assignment Using concepts from chapters 1 – 5 only. Grading will be...
C++ Chapter 4/5 Lab Assignment Using concepts from chapters 1 – 5 only. Grading will be based on chapter 4 concepts more. Design a menu driven program that can keep track of five player’s scores. Your program must have the following documentation: A. Your name B. The program name C. Program Description D. The date the exe file was created E. The code: a. Use a menu approach do the following: i. to Add a player information ii. to Search...
According to her doctor, Mrs. Brown's cholesterol level is higher than only 5% of the females...
According to her doctor, Mrs. Brown's cholesterol level is higher than only 5% of the females aged 50 and over. The cholesterol levels among females aged 50 and over are approximately normally distributed with a mean of 235 mg/dL and a standard deviation of 25 mg/dL. What is Mrs. Brown's cholesterol level? Carry your intermediate computations to at least four decimal places. Round your answer to one decimal place.
Mrs. Jones is a 46 yesrs old was admitted with a diagnosis of ulcerative colitis. she...
Mrs. Jones is a 46 yesrs old was admitted with a diagnosis of ulcerative colitis. she is to receive vancomycin 500 mg IV piggyback every 6 hours. Describe the nursing implications when patients receive vancomycin. Explain peak and through.
Mrs Jones is the owner of a large racehorse stud and horse training business. She employs...
Mrs Jones is the owner of a large racehorse stud and horse training business. She employs eight staff and holds a training licence. Mrs Jones’ involvement in the racing business is her full-time occupation and she attends as many race meetings as possible (over one per week). Mrs Jones is also a very keen punter, betting on both her own and other horses, and during the last year she had several very big wins which netted her $120,000 in winnings...
Mrs. B comes to the clinic today because she felt a lump in her breast. She...
Mrs. B comes to the clinic today because she felt a lump in her breast. She is extremely anxious and wants to know if she is going to die. (Learning Objectives: 10, 11, 14, and 18) 1. If you were the nurse who greets Mrs. B, how might you respond to her concerns and anxiety? 2. What are some questions that may be helpful in identifying any risk factors she may have for any type of cancer? Give the rationale...
Mrs. X was getting out of her car, when she slammed the car door on her...
Mrs. X was getting out of her car, when she slammed the car door on her knee, hurting it quite badly, even though there was no broken skin or bleeding. The knee became very swollen and painful within the first couple of hours of the injury, making it difficult to walk, so Mrs. X went to an emergency room to check her knee. Explain what happened here at the cellular level (use the inflammatory reaction cascade to answer step by...
Mrs. Smith is approaching her 80th birthday. She is adamant about her health including her healthy...
Mrs. Smith is approaching her 80th birthday. She is adamant about her health including her healthy bones, so she’s been taking calcium supplements for over 40 years. Should she consume her calcium supplements with meals or between meals? Explain your answer. What other nutrients should Mrs. Smith be careful about?
5) A lumber grading system is known to be defective 20% of the time. When the...
5) A lumber grading system is known to be defective 20% of the time. When the machine works properly, 20% of the lumber that passes through is rejected, but 50% of the pieces are rejected when it is defective,. In either case, pieces that are accepted are graded this way: 20% #1 Grade 70% #2 Grade 10% #3 Grade a. Draw a tree diagram outlining each possible outcome. Include all of the relevant probabilities as well as the probability for...
A large University system, which currently uses a standard grading system of A, B, C, D...
A large University system, which currently uses a standard grading system of A, B, C, D or F for their students, is analyzing the possibility of changing to a plus-minus grading policy. In addition to the computer system, which stores and manages all the student records, the faculty and the students would also be affected by this possible change. One of the concerns that students have, is that changing this policy might lower the overall GPA (grade point average) of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT