Using C Write a program that performs the following 1 Presen

Using C++

Write a program that performs the following:

1. Presents the user a menu where they choose between:

             a. Add a new student to the class

                          i. Prompts for first name, last name

                          ii. If assignments already exist, ask user for new student’s scores to assignments

             b. Assign grades for a new assignment

                          i. If students already exist, prompt user with student name, ask them for score

                          ii. Students created after assignment will need to have score provided

             c. List one student, displaying all their grades and their course average

                          i. Prompt user for student, telling them which inputs are valid

                          ii. If no students and/or no assignments, tell user to try after data input

             d. List all the scores for a chosen assignment

                          i. Prompt user for assignment, telling them which options are valid

                          ii. includes class average

                          iii. if no valid assignments and/or students, tell user to try after data input

             e. Display all grades currently contained in the gradebook

                          i. If no students, tell user gradebook is empty

              f. Exit the program

2. Return to step 1

For your program you will be using an array (size: 10 elements) of the Student struct, which contains First Name, Last Name (char arrays or strings), and 10 assignment scores (double). Keep track the number of students and number of assignments with variables (might need to pass them to functions as arguments). If the user tries to add students or assignments when they are already full, they should get an error message.

Input should accept either a single lowercase char or an integer, prompts should tell user what to enter.

Solution

#include <iostream>
using namespace std;
#define MAX 10
int sp=-1;
int ap=-1;

typedef struct Student
{
string FirstName,LastName;
double assn_scores[10];
};

struct Student students[MAX];

void insert_s(struct Student s)
{
if(sp == MAX-1)
cout << \"\ Maximum capacity of the class has reached\" ;
else
{
students[++sp] = s;
}
}

void insert_a()
{
if(ap == (10)-1)
cout << \"\ Maximum number of assignments excedded\" ;
else
{
ap++;
}
}

void printDetails(string fname,string lname)
{
double sum=0.0;
for(int i=0;i<=sp;i++)
{
if(students[i].FirstName==fname && students[i].LastName==lname)
{
cout<<\"\ Name : \" << fname<<\" \"<<lname;
for(int j=0;j<=ap;j++)
{
cout<<\"\ Assignment \"<<j<<\" :\"<<students[i].assn_scores[j];
sum=sum+students[i].assn_scores[j];
}
sum=sum/ap;
cout<<\"\ Course Average :\"<<sum;
}
}
}

void printAssnDetails(int inp)
{
double sum=0.0;
cout<<\"\ Assignment \"<<inp<<\":\";
for(int i=0;i<=sp;i++)
{
cout<<\"\ \"<<students[i].FirstName<<\" \"<<students[i].LastName<<\" :\"<<students[i].assn_scores[inp];
sum=sum+students[i].assn_scores[inp];
}
sum=sum/ap;
cout<<\"\ Class Average :\"<<sum;
}
  
void displayGradeBook()
{
for(int i=0;i<sp;i++)
{
cout<<\"\ Name : \" << students[i].FirstName<<\" \"<<students[i].LastName;
for(int j=0;j<=ap;j++)
{
cout<<\"\ Assignment \"<<j<<\" :\"<<students[i].assn_scores[j];
cout<<\"--------------------------------------------------------------------------------------------------\";
}

}

}

int main()
{
int ch=0,inp=0;
string lname,fname;
struct Student std;

cout<<\"Menu\ \";
cout << \"1: Add a new student to the class\ \" ;
cout << \"2: Assign grades for a new assignment\ \" ;
cout << \"3: List one student, displaying all their grades and their course average\ \" ;
cout << \"4: List all the scores for a chosen assignment\ \" ;
cout << \"5: Display all grades currently contained in the gradebook\ \" ;
cout << \"6: Exit\ \";

while(inp==0)
{
cout << \"Enter your choice\" ;
cin >> ch;
switch(ch)
{
case 1:
cout << \"\ Enter your first name\" ;
cin >> std.FirstName;
cout << \"\ Enter your last name\" ;
cin >> std.LastName;
if(ap!=-1)
{
for(int i=0;i<=ap;i++)
{
cout << \"\ Enter the score for assignment :\" <<i;
cin >> std.assn_scores[i];
}
}
insert_s(std);
break;

case 2:
insert_a();
if(sp!=-1)
{
for(int j=0;j<=sp;j++)
for(int i=0;i<=ap;i++)
{
cout << \"\ Enter the score for assignment \" <<i<<\" of \"<<students[j].FirstName<<\" \" <<students[j].LastName;
cin >> students[j].assn_scores[i];
}
}
break;

case 3:
cout << \"\ Enter your first name :\" ;
cin >> fname;
cout << \"\ Enter your last name :\" ;
cin >> lname;
printDetails(fname,lname);
break;
case 4:
cout << \"\ Enter the assignment number :\" ;
cin >> inp;
printAssnDetails(inp);
inp=0;
break;
case 5:
displayGradeBook();
break;
case 6:
inp=0;
break;
default:
cout << \"\ Wrong Input. Try Again\ \";
break;
}
}
return 0;
}

Using C++ Write a program that performs the following: 1. Presents the user a menu where they choose between: a. Add a new student to the class i. Prompts for f
Using C++ Write a program that performs the following: 1. Presents the user a menu where they choose between: a. Add a new student to the class i. Prompts for f
Using C++ Write a program that performs the following: 1. Presents the user a menu where they choose between: a. Add a new student to the class i. Prompts for f
Using C++ Write a program that performs the following: 1. Presents the user a menu where they choose between: a. Add a new student to the class i. Prompts for f

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site