#include<bits/stdc++.h>
#include<stdlib.h>
using namespace std;
typedef struct // Naming for student
{
char fastName[50];
char lastName[50];
} nametype;
typedef struct
{
char ID[150];
char grade[150];
nametype name;
} studentInfo;
studentInfo student[100];
int marks[500];
void gradeFunc(studentInfo *s, int mark)
{
if(mark >= 80)
{
strcpy(s -> grade,"A+");
}
else if(mark >= 70)
{
strcpy(s -> grade,"A");
}
else if(mark >= 60)
{
strcpy(s -> grade,"A-");
}
else if(mark >= 50)
{
strcpy(s -> grade,"B");
}
else if(mark >= 40)
{
strcpy(s -> grade, "C");
}
else
{
strcpy(s -> grade,"F");
}
}
void printfStudentInfo()
{
cout<<endl;
printf("**************************Result Board**************************\n\n");
printf("Sl.\tName\t\t\tID\t\tGrade\t\t\n\n");
for(int i=0; i<2; i++)
{
printf("%d.\t%s %s\t\t\t%s\t\t\%s\n",i+1,student[i].name.fastName,student[i].name.lastName,student[i].ID,student[i].grade);
}
cout<<endl<<endl;
}
void takeIn(int n)
{
for(int i=0; i<n; i++)
{
printf("Enter the first name for the student %d: ",i+1);
scanf(" %[^\n]",&student[i].name.fastName);
printf("Enter the last name for the student %d: ",i+1);
scanf(" %[^\n]",&student[i].name.lastName);
printf("Enter the ID for student %d: ",i+1);
scanf(" %[^\n]",&student[i].ID);
getchar();
printf("Enter the grade for the student %d: ",i+1);
scanf("%d",&marks[i]);
cout<<endl;
}
for(int j=0; j<2; j++)
{
gradeFunc(&student[j],marks[j]);
}
}
int main()
{
int n_students;
printf("How many students: ");
scanf("%d",&n_students);
takeIn(n_students);
printfStudentInfo();
return 0;
}