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

C++ Program flow: 1. Input data 2. Check/validate data 3. Calculate final grade

ID: 3571363 • Letter: C

Question

C++ Program flow: 1. Input data 2. Check/validate data 3. Calculate final grade 4. Output data Requirements: 1. The number of students to enter will be 10. 2. Using a struct, you will keep track of a student's: a. first name b. last name c. student ID d. 4 exam grades (each out of 100 points) e. final letter grade. 3. For each student, if the user enters invalid data he will be allowed to enter it again. 4. Steps 3 and 4 of the Program Flow cannot execute if your data checking detected an error. 5. Letter grade calculation will use the standard grading scale. a. 90% - 100% = A b. 80% - 89% = B c. 70% - 79% = C d. 60% - 69% = D e. Below 60% = F 6. The output will consist of: a. A list of students who passed (C or higher) b. A list of students who did not pass (D or lower) c. The person(s) with the highest grade (points, not letter) Restrictions: 1. main() will only consist of variable declarations, functions, and small amounts of logic, if necessary. The majority of the logic will reside in the core functions. 2. In the student struct, the exam grades must be stored as an array, not 4 separate variables. 3. For Program Flow 2: use a function 4. For Requirement 3: use a try/catch and a loop Example output ------------- PASS ---- Aberdeen, Joe A Blake, Kevin A Garry, Glen C Jenakovski, Mary B FAIL ---- Zoolander, Derek F HIGHEST GRADE ---- Blake, Kevin A

1. Allow the user to specify the number of students to be entered 2. Allow spaces in the first or last name 3. Protect against bad data, in addition to that which is required in Requirement 3 4. Use a recursive function for Requirement 6c

Explanation / Answer

#include<iostream>
#include<stdlib.h>
using namespace std;
//Structure student
struct Student
{
string firstName, lastName, studentID;
char grades;
double points;
};
typedef struct Student ss;
//Input method
void Input(ss s[], int n)
{
int po;
//Accept data for N students
for(int x = 0; x < n; x++)
{
//Validates point mark. If invalid asks for reenter
cout<<" Enter Student First Name: ";
cin>> s[x].firstName;
cout<<" Enter Student Last Name: ";
cin>> s[x].lastName;
do
{
cout<<" Enter Student Point: ";
cin>> po;
if(po >= 0 && po <= 100)
{
s[x].points = po;
break;
}
else
cout<<"Error: Invalid points Reenter the point: ";

}while(1);
}

}
//Calculates Grade
void Grade(ss s[], int n)
{
//Calculates grade for N students
for(int x = 0; x < n; x++)
{
if(s[x].points >= 90)
s[x].grades = 'A';
else if(s[x].points >= 80)
s[x].grades = 'B';
else if(s[x].points >= 70)
s[x].grades = 'C';
else if(s[x].points >= 60)
s[x].grades = 'D';
else
s[x].grades = 'F';
}
}
//Displays the pass and fail student information
void OutputStatus(ss s[], int n)
{
cout<<" ---------------------- PASS ---------------------- ";
for(int x = 0; x < n; x++)
{
//Checks for the pass grade
if(s[x].grades == 'A' || s[x].grades == 'B' || s[x].grades == 'C' || s[x].grades == 'D' )
{
cout<<s[x].firstName<<", "<<s[x].lastName<<" "<<s[x].grades<<endl;
}
}
cout<<" ---------------------- FAIL ---------------------- ";
for(int x = 0; x < n; x++)
{
//Checks for the fail grade
if(s[x].grades == 'F')
{
cout<<s[x].firstName<<", "<<s[x].lastName<<" "<<s[x].grades<<endl;
}
}
}
//Displays the highest point secured by a student
void OutputHighestGrade(ss s[], int n)
{
int po = 0;
for(int x = 0; x < n; x++)
{
double high = s[0].points;
//Checks for the highest point
if(s[x].points > high)
{
high = s[x].points;
po = x;
}
}
cout<<" HIGHEST GRADE --- "<<s[po].firstName<<", "<<s[po].lastName<<" "<<s[po].grades<<endl;
}
int main()
{
int no;
//Asks for the number of students
cout<<" Enter how many Students information you want? ";
cin>>no;
//Creates array of object as per the number of students
ss *st = new ss[no];
//Calls the accept function
Input(st, no);
//Calls the grade calculate function
Grade(st, no);
//Calls the OutputStatus function for pass and fail student information
OutputStatus(st, no);
//Calls the OutputHighestGrade function to displays student secured highest point
OutputHighestGrade(st, no);
}

Output:

Enter how many Students information you want? 6

Enter Student First Name: Pyari

Enter Student Last Name: Sahu

Enter Student Point: 101
Error: Invalid points Reenter the point:
Enter Student Point: 98

Enter Student First Name: Sasmita

Enter Student Last Name: Sahu

Enter Student Point: 78

Enter Student First Name: Amiya

Enter Student Last Name: Swain

Enter Student Point: -7
Error: Invalid points Reenter the point:
Enter Student Point: 85

Enter Student First Name: Rakesh

Enter Student Last Name: Padhi

Enter Student Point: 56

Enter Student First Name: Bishnu

Enter Student Last Name: Sahu

Enter Student Point: 68

Enter Student First Name: Suresh

Enter Student Last Name: Swain

Enter Student Point: 32

---------------------- PASS ----------------------
Pyari, Sahu A
Sasmita, Sahu C
Amiya, Swain B
Bishnu, Sahu D

---------------------- FAIL ----------------------
Rakesh, Padhi F
Suresh, Swain F

HIGHEST GRADE --- Pyari, Sahu A

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