Write a program to complete the following tasks and record the outputs to a data
ID: 3536037 • Letter: W
Question
Write a program to complete the following tasks and record the outputs to a data file named "EGR126-Final.dat". Outputs should include headings (Students's ID, Name and Grade). 1. using one dimensional array to genderate a grade sheet for a class with 10 students. The IDs and Names are listed as follows ID Name 225 John 378 Ken 952 Mary 833 Frank 178 Cathy 688 Rudy 592 Andy 267 Michael 823 Helen 743 Pat 2. According the following students. Write a module to genderate random grade ( with 2 decimal places) for each student. print the class roster(with student grades) to data file *failing rate is 35% *passing grade is between 60 and 100. *failing grade is between 0 and 59.99 *apply srand() function in the program. *set grade precision to 2 decimal places. 3. Write a module to determine letter grade for each student. print the updated transcript (with letter grades) to the data file. 'A' : 100 =>grade=>90 'B' : 90 =>grade=>80 'C' : 80 =>grade=>70 'D' : 70 =>grade =>60 'F" : 0 <=grade <60 4. Determine the number of student receive an "A".Explanation / Answer
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
struct student
{
char name[30];
int id;
float grade;
char G;
};
void main()
{
fstream file;
file.open("EGR!@^-Final.dat");
student a[10];
int i;
cout<<"enter student details ";
for(i=0;i<10;i++) // module 1.
{
cout<<"enter name and iD of a student ";
cin>>a[i].name>>a[i].id;
a[i].grade=rand()0; // random grade module 2
if(a[i].grade<=100 && a[i].grade>=90) // assign grade
{
cout<<"Grade is A";
a[i].G='A';
}
if(a[i].grade<=90 && a[i].grade>=80)
{
a[i].G='B';
cout<<"Grade is B";
}
if(a[i].grade<=80 && a[i].grade>=70)
{
cout<<"Grade is C";
a[i].G='C';
}
if(a[i].grade<=70 && a[i].grade>=60)
{
cout<<"Grade is D";
a[i].G='D';
}
if(a[i].grade<=60 && a[i].grade>=00)
{
cout<<"Grade is F";
a[i].G='F';
}
file.write((char*)&a[i],sizeof(a[i]));
}
int b=0; // print number of student Getting A
for(i=0;i<10;i++)
{
if(a[i].G=='A')
b++;
}
cout<<"total Numbe rof Student getting Grade A is "<<b;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.