In this quest, you are going to modify quest 2 so that it saves your class roste
ID: 3598429 • Letter: I
Question
In this quest, you are going to modify quest 2 so that it saves your class roster to a file and can load from that file. This is quest 2 code #include #include using namespace std; #define ASSI 10 int main() { int ns,i=0, j=0, total =0,points,grade[30][10]; //variable declaration part float Avg; string students[30]; //can store 30 students string name; int assiNo =0; int assiGrade =0; char ch; string AssiName;// for edit part cout <<"Enter Assignment name"<> AssiName; while(1) // loop up to user want { cout <<"Enter the number of students in the class:"<< endl;//ask the user to enter no of students cin >> ns;//ask the user to enter no of students cin.ignore (256,' '); for(i=0;i>students[i];//enter student cin.ignore(256,' '); // for ignore cout << "Please enter grades for 10 assignments"<> grade[i][j]; //enter grade cin.ignore(256,' '); } } system ("clear"); // clear system while(i++ < 50) // put border cout <<"="; cout< 70)//check curve { cout << "There is no curve." << endl; } else { cout << "You need to had 5 points."<>ch; if(ch == 'y' || ch == 'Y') // want to change entry? { cin.ignore(256,' '); cout << "Enter student name"<>name; cout << "name" << name << endl; i=0; while(!name.compare(students[i]))//check student name available or not i++; i--;//for array if(i> ns) cout << "No any student found"<> assiNo; if(assiNo >= 10)//if entered more then 10 go to label { cout << "Wrong Assignment no" << endl; goto label; } cin.ignore(256,' '); cout << " Enter grade of assignment"; cin >> assiGrade; grade[i][assiNo-1] = assiGrade; cout< 70)//check for curve { cout << "There is no curve." << endl; } else { cout << "You need to had 5 points."<>ch; if(ch != 'y' || ch != 'Y') return 0; } return 0; } This code needs to be modified so that it saves my class roster to a file and can load from that file. Please help with this.
Explanation / Answer
include <iostream>
#include <stdlib.h>
using namespace std;
#define ASSI 10
int main()
{
int ns,i=0,j=0,total =0,points,gread[30][10]; // veriable declaration part
float Avg;
string students[30]; // can store 30 students
string name;
int assiNo =0;
int assiGread =0;
char ch;
string AssiName; // for edit part
cout <<"Enter Assignment name"<<endl;
cin >> AssiName;
while(1) // loop up to user want
{
lable1:
cout<<"Enter the number pf students in the class:";
cin >> ns; // ask to user to enter no of student
if(ns>30)
{
cout << "Maximun student should be 30" <<endl;
goto lable1;
}
cin.ignore(256,' '); // one character we need to floush from cin
for(i=0;i<ns;i++) // students loop
{
cout<<"Please enter name of student"<<endl;
cin>>students[i]; // enter student
cin.ignore(256,' '); // for ignor
cout << "Please enter greads for 10 assignments"<<endl;
for(j=0;j<ASSI;j++)
{
cin >> gread[i][j]; //enter gread
cin.ignore(256,' ');
}
}
system("clear"); // clear system
while(i++ < 50) // put border
cout <<"=";
cout<<endl;
i =0;
cout <<" " <<AssiName << endl;
i = 0;
while(i++ < 50)
cout <<"=";
cout<<endl;
for(i=0;i<ns;i++) // display details
{
Avg = 0;
total = 0 ;
cout << students[i];
for(j=0;j<ASSI;j++)
{
cout <<" "<<gread[i][j];
total = total + gread[i][j]; // colect total of greads
}
Avg = total/ASSI;
if(Avg > 70) //check curve
{
cout << "There is no curve." << endl;
}
else
{
cout << "You need to had 5 points."<<endl;
}
}
cout<< "Want to change student gread ? yes - y/Y no - n/N " << endl; // edit entry part
cin>>ch;
if(ch == 'y' || ch == 'Y') // want to change entry?
{
cin.ignore(256,' ');
cout << "Enter student name"<<endl;
cin>>name;
i =0;
while(!name.compare(students[i])) // check student name is available or not
i++;
i--; // for array
if(i> ns)
cout << "No any student found"<<endl;
else
{
lable: // if wrong assignment number start again from here
cin.ignore(256,' ');
cout << "Enter assignment no"<<endl;;
cin >> assiNo;
if(assiNo >= 10) // if entered more then 10 go to lable
{
cout << "Wrong Assignment no" <<endl;
goto lable;
}
cin.ignore(256,' ');
cout << " Enter gread of assignment";
cin >> assiGread;
gread[i][assiNo-1] = assiGread; // store in perticulare assi.
cout<<students[i]; //print detail of edited student list
total = 0;
Avg =0;
for(j=0;j<ASSI;j++)
{
cout <<" "<<gread[i][j];
total = total + gread[i][j];
}
Avg = total/ASSI;
if(Avg > 70) // check for curve
{
cout << "There is no curve." << endl;
}
else
{
cout << "You need to had 5 points."<<endl;
}
}
}
cout<< "Want to exit ? yes - y/Y no - n/N " << endl; // want to exit or continue?
cin>>ch;
if(ch == 'y' || ch == 'Y')
return 0;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.