You are to write a program that will allow Apollo College to maintain the marks and grades of its students in a programming class.

Assume there are ten students in the class. Your program will need to store the following information for each of the students:

1. Student’s name, to be stored as a string
2. Student’s mark, to be stored as a floating-point number,
3. Student’s grade, to be stored as a single character.

The program will initially input the data for the ten students. Once the data have been read in from the keyboard, the program will allow the user the option of performing any of the following tasks:

A. Print out the information for all ten students. This includes the name, mark and grade of each student. The output should be properly formatted.

B. Print out the information of all students who scored grade A.

C. Print out the information of all students who scored less than 50.0 marks.

D. Print out the number of students who scored less than 50.0 marks. For this task, you must implement a function which has the following prototype:

int numOfStudFailed( float arr[] );


The parameter is the array that stores the marks of the ten students. The function returns the number of students who scored less than 50.0 marks.


E. Compute the average mark of students in the class. For this task, you must implement a function which has the following prototype:

void computeAverage( float arr[], float *average );

The parameter arr is the array that stores the marks of the ten students. The calculated average mark should be assigned to the second parameter average, so that it can be printed out by the caller of the function.

F. Given a student name (input by the user), print out all the information for that student.

G. Exit the program

Where is the question (or question mark)?

Since it is not expected for us to deliver full homework solutions, what question did you have about this?

Which part is giving you a problem?

This will get you started.

#include <iostream>
using namespace std;
string studentName[10];
float studentMark[10];
char studentGrade[10];

char getGradeByMark(float mark){
    int iMark=(int)(mark/10);
    switch(iMark){
        case 10:
        case 9:
            return 'A';
        case 8:
            return 'B';
        case 7:
            return 'C';
        case 6:
            return 'D';
        default:
            return 'F';
    }
}

void getStudentData(int student){
    cout<<"Input name for student #"<<(student+1)<<": ";
    getline (cin,studentName[student]);
    cout<<"Input grade for student #"<<(student+1)<<": ";
    studentGrade[student]=getGradeByMark(studentMark[student]);
}




int main(){
    bool done=false;
    int option;
    for(int i=0;i<10;i++){
        getStudentData(i);
    }
    while(!done){
        cout<<"<List options>"<<endl;
        cout<<"Please select one of the options:";
        cin>>option;
        switch(option){
            case 1:
                cout<<"First option selected. There should probably be a function here."<<endl;
                break;
            case 2:
                cout<<"Second option selected. There really should be a function here."<<endl;
                break;
            case 3:
                cout<<"Third option selected. I suppose I'm lazy."<<endl;
                break;
            case 4:
                cout<<"Fourth option selected. This is not the option you are looking for."<<endl;
                break;
            default:
                cout<<"Exiting..."<<endl;
                done=true;
                break;

        }

    }
    return 0;
}

Edited 4 Years Ago by DeanMSands3: n/a

Comments
Dont give them the answer they have done nothing !
This article has been dead for over six months. Start a new discussion instead.