The school maintains records containing information about students of each grade
ID: 3917934 • Letter: T
Question
The school maintains records containing information about students of each grade. Each record contains a student’s first name, last name and grade number. The grades are:
Grade Number
Grade Name
1
First Grade
2
Second Grade
3
Third Grade
4
Fourth Grade
5
Fifth Grade
Design a program using pseudocode that accepts the student's first name, last name and grade number and creates a report that lists each student's last name along with his or her grade name. Use a modular design to solve the problem. Hint: Use parallel arrays to store the grade number and grade name.
Grade Number
Grade Name
1
First Grade
2
Second Grade
3
Third Grade
4
Fourth Grade
5
Fifth Grade
Explanation / Answer
In this code you have one restriction that you only use your input as it is given
#include <iostream>
#include<bits/stdc++.h>
#define N 2 //Number of Student as You Wants to enter
using namespace std;
//Student Record For storing The first Name and last Name and grade number
struct studentrecord
{
char first_name[20];
char last_name[20];
int grade_num;
};
//For storing Grade List Grade number along with Grade name
struct gradeRecord{
int grade_num;
char grade_name[20];
};
int main()
{
int i;
//start Storing Grade list as You wish You can store your Listhere as example for garde no. 1 your grade is First Grade.
struct gradeRecord gr[5];
cout<<" Enter Grade Record"<<endl<<endl;
for(i=0;i<5;i++)
{
cout<<"Enter Grade Number: ";
cin>>gr[i].grade_num;
fflush(stdin);
cout<<"Enter Grade Name: ";
cin.getline(gr[i].grade_name,20);
}
cout<<endl<<"Grade List"<<endl;
cout<<"________________________________"<<endl;
cout<<"Grade Number| Grade Name "<<endl;
cout<<"________________________________"<<endl;
//Printing The Grade list as My Input Given
for(i=0;i<5;i++)
{
cout<<gr[i].grade_num<<" "<<gr[i].grade_name<<" "<<endl;
}
cout<<"________________________________"<<endl<<endl<<endl;
struct studentrecord stu[N];
//Entering Student Record as First name, Last Name, Grade number.
for(i=0;i<N;i++)
{
fflush(stdin);
cout<<" Enter Student First Name: ";
cin.getline(stu[i].first_name,20);
fflush(stdin);
cout<<"Enter Student Last Name: ";
cin.getline(stu[i].last_name,20);
fflush(stdin);
cout<<"Enter Student Grade number: ";
cin>>stu[i].grade_num;
cout<<endl;
}
//Printing The Last Name and Student Grade
cout<<endl;
cout<<"Last Name | " <<" Student Grade"<<endl;
for(i=0;i<N;i++)
{
cout<<stu[i].last_name<<" "<<gr[gr[i].grade_num].grade_name<<endl;
}
}