Hey everyone, I need some help with this c++ program. This program prettymuch ac
ID: 3616227 • Letter: H
Question
Hey everyone,I need some help with this c++ program. This program prettymuch accepts data from multiple students and prints it out in thisformat.
Here is the data of students:
Student #1:
Date of Matriculation:
Address:
GPA:
Course #1 Quiz1 Quiz 2 MT Final
Course #2
Course #3
Course #4
Course #5
Course #6
Course #7
Course #8
Course #9
Course #10
This should be printed out for multiple students.
I have written a code which accepts the data properly but I amhaving problem in calculating GPA and course grades. I am messingup somewhere in my loops. I am posting my source code below, pleasehelp me out! I will definitely rate you.
#include <iostream>
using namespace std;
const int Addr_Length=40;
const int City_Length=20;
const int State_Length=15;
const int Zip_Length=10;
const int Num_Students=2;
const int Num_Courses=10;
struct Date{
int month;
int day;
int year;
};
struct Course{
double q1,q2,mt,final,total;
};
struct Place{
char address[Addr_Length];
charcity[City_Length];
char state[State_Length];
char zip[Zip_Length];
};
struct Student{
Date Matriculation;
Place residence;
Course subject;
};
int main(){
Student newStudent[Num_Students];
Course newCourse[Num_Courses];
cout<<"Here is the information of all thestudents:"<<endl<<endl;
for(int k=0;k<Num_Students;k++){
for(int i=0;i<Num_Courses;i++){
cout<<"Enter score of quiz 1 of Student#"<<(k+1)<<" for course #"<<(i+1)<<":";
cin>>newCourse[i].q1;
cout<<"Enter score of quiz 2 of Student#"<<(k+1)<<" for course #"<<(i+1)<<":";
cin>>newCourse[i].q2;
cout<<"Enter score of midterm of Student#"<<(k+1)<<" for course #"<<(i+1)<<":";
cin>>newCourse[i].mt;
cout<<"Enter score of final of Student#"<<(k+1)<<" for course #"<<(i+1)<<":";
cin>>newCourse[i].final;
}
cout<<"Enter Date of Matriculation forstudent"<<(k+1)<<" ";
cout<<"Month (2 digits): ";
cin>>newStudent[k].Matriculation.month;
cout<<"Day (2 digits): ";
cin>>newStudent[k].Matriculation.day;
cout<<"Year (2 digits): ";
cin>>newStudent[k].Matriculation.year;
cin.ignore();
cout<<"Enter street address of the student #"<<(k+1)<<": ";
cin.getline(newStudent[k].residence.address,Addr_Length);
cout<<"City: ";
cin.getline(newStudent[k].residence.city,City_Length);
cout<<"State: ";
cin.getline(newStudent[k].residence.state,State_Length);
cout<<"Zip Code: ";
cin.getline(newStudent[k].residence.zip,Zip_Length);
}
cout<<"Here are the data for the students:"<<endl;
for(int index=0;index<Num_Students;index++){
for(inti=0;i<Num_Courses;i++){
double qt1,qt2,QT,MT,FINAL;
qt1=(newCourse[i].q1)*1.25;
qt2=(newCourse[i].q2)*1.25;
QT=qt1+qt2;
MT=(newCourse[i].mt)*.25;
FINAL=(newCourse[i].final)*0.5;
newCourse[i].total=QT+MT+FINAL;
cout<<"Course#"<<(i+1)<<" Quiz1"<<" Quiz2"<<" MidTerm"<<" Final"<<endl<<endl;
cout<<" "<<endl<<newCourse[i+1].q1;
}
}
system("pause");
return 0;
}