Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help What did i do wrong, my code wont let me enter in grades and it keeps repea

ID: 662892 • Letter: H

Question

Help What did i do wrong, my code wont let me enter in grades and it keeps repeating names and id numbers,,

#include <iostream>
#include <string>
using namespace std;

struct Grade
{
   char studentFname[50];
   char studentLname[50];
   char assignment[10];
   char exam[3];
   char final[3];
   int id;
   //declaring my variables
};

int main()
{
   char assignment[10];
   char exam[3];
   char final[3];
   struct Grade Grade1;
   cout << "Enter Students first name: ";//first name
   cin >> Grade1.studentFname;
   cout << "Enter Students last name "; //last name
   cin >> Grade1.studentLname;
   cout << "Enter Students ID number: ";
   cin >> Grade1.id;
   int i;
   for (i = 0; i < 10; i++){

       Grade1.exam[0] = 'C' ;
       Grade1.exam[1] = 'A' ;
       Grade1.exam[2] = 'B'; //This will be all the exam grades

       Grade1.final[0] = 'B';
       Grade1.final[1] = 'C';
       Grade1.final[2] = 'A'; //This will be the final grades

       cout << "Student firstname : " << Grade1.studentFname << endl;
       cout << "Student lastname : " << Grade1.studentLname << endl;
       cout << "Student id : " << Grade1.id << endl; //these print the students information
   }
   for (i = 0; i<10; i++){
       cout << "Students assignment grades : " << Grade1.assignment[i] <<endl;
       cin >> assignment;
   }
   for (i = 0; i<3; i++){
       cout << "Students exam grades : " << Grade1.exam[i] <<endl;
       cin >> exam;
   }
   for (i = 0; i<3; i++){
       cout << "Students final grades : " << Grade1.final[i] <<endl;
       cin >> final;
   }
   system("pause");
   return 0;
}

Explanation / Answer

Answer

To remove repeating names,id . Reome below for-loop

for (i = 0; i < 10; i++){          //Remove This For loop line

       Grade1.exam[0] = 'C' ;
       Grade1.exam[1] = 'A' ;
       Grade1.exam[2] = 'B'; //This will be all the exam grades

       Grade1.final[0] = 'B';
       Grade1.final[1] = 'C';
       Grade1.final[2] = 'A'; //This will be the final grades

       cout << "Student firstname : " << Grade1.studentFname << endl;
       cout << "Student lastname : " << Grade1.studentLname << endl;
       cout << "Student id : " << Grade1.id << endl; //these print the students information
   } //This line also