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

I want it to be done in C++. And my file should be formatted in file.cpp (not in

ID: 3788498 • Letter: I

Question

I want it to be done in C++. And my file should be formatted in file.cpp (not in file.c). The file should be prog02_myname.cpp. I can put my name later. Thank you so much.

Chrome File Edit View History Bookmarks People Window Hel C Secure https: tracs.txstate.edu access/content chment/73 Apps D suggested sites a Amazon.com On D Ebay HP See what's Hot HP Games Web slice Gallery Imported From IE Zippyshare.com PROJECT#2 [Student Grades] Due Date: Displayed on TRACS 100 points CS 2308 of Co ter Science Texas State Universi The program will print a grade report for students in a course. Input: An instructor has a class of no more than 40 students each of whom takes 6 tests. For each student in the class, there is one line in the input file. The line contains the student's first name (no more than 10 characters, last name (no more than 12 characters), ID# (a string of 6 characters) and 6 integer test scores. Input text file should be named student input.dat Example of file input Adam Zelle er 452313 78 86 91 64 90 7 274253 BB 77 91 66 82 93 Carl Wilson. 112235 87 99 93 94 Note that a different file will be used for testing. Also note that amount of blank spaces between names, ID, and grades can be arbitrary, i.e., any number. There will be at least one space though. There might be a space between the last grade and the invisible symbol that signifies the end of the line 'In' Total amount of characters for each line will not exceed 256, including the end of the line symbol Processing: The program is to read the input file and calculate each student's average and letter grade for the course. The average is calculated by dropping the student's lowest test score and then averaging the remaining 5 scores. In addition, the number of students receiving each letter grade (A, B, C, D, or F for the course is to be calculated. The cutofffor the letter grades is 89.5 for an A, 79.5 for a B, 69.5 for a C, 59.5 for a D output: The program is to print to an output file (student results.da a table showing each student's name (Last, First), identification number, course average (rounded to 1 decimal place) 35% Tue Feb 7 12:38 AM a E nhat Other Bookmarks 7Loader ISO. Ink Screen Shot 36 AM 2015-02...9.23 PM a.cpp Screen Shot 5 PM 2015-02...9.25 PM oad com.lsreset Screen Shot 9 PM 2015-02...9.29 PM crack Screen Shot 7 PM 2015-02...9.31 PM FPT Play 1.02 ipa Screen Shot 5 PM 2015-07., 4.36 PM Screenshot 2015 PM 2016-03...8.46 PM

Explanation / Answer

/*

I have spent lot of time in solving this problem, its mostly correct. if you have any doubts you can contact me at dhruvjain.1027 at g m ail

Give full marks dude.

*/

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;

void checknegative(int num){
   if(num<0){
      cout<<"Negative grade present"<<endl;
      exit(0);
   }
}

void getaverage(float avg_score[40],int id,int scores[6],int min_grade){
   if(min_grade==-1){
       avg_score[id] = 1.0*(scores[0]+scores[1]+scores[2]+scores[3]+scores[4])/5;
       return;
   }
   avg_score[id] = 1.0*(scores[0]+scores[1]+scores[2]+scores[3]+scores[4]+scores[5]-min_grade)/5;

}

char get_grade(float marks){
   if(marks>=89.5)
       return 'A';
   else if(marks>=79.5)
       return 'B';
   else if(marks>=69.5)
       return 'C';
   else return 'D';
}
int getmingrade(int scores[6],int num_subj){
   int min_g = 100;
   for(int i=0;i<num_subj;i++)
       min_g = min(min_g,scores[i]);
   return min_g;
}
int main(){

  
   char input[256];
   char firstname[40][10];
   char lastname[40][10];
   char id_char[40][6];
   float avg_score[40];
   char grade[40];
   int gradetotal[4];
   int j=0;
   memset(gradetotal,0,sizeof(gradetotal));
   memset(firstname,0,sizeof(firstname));
   memset(lastname,0,sizeof(lastname));
   memset(id_char,0,sizeof(id_char));
   memset(grade,0,sizeof(grade));

   while (cin.getline(input,sizeof(input)))
   {  
      
       int i=0;
      while(input[i]!=''){
          int k=0;
          while(input[i]!=' '){
              firstname[j][k]=input[i];
              i++;k++;
          }
         
          while(input[i]==' ')
              i++;
          k=0;
          while(input[i]!=' '){
              lastname[j][k]=input[i];
              i++;k++;
          }
         
          while(input[i]==' ')
              i++;
          k=0;
          while(input[i]!=' '){
              id_char[j][k]=input[i];
              i++;k++;
          }
         
          while(input[i]==' ')
              i++;
          int scores[6];
          memset(scores,-1,sizeof(scores));
          char mark[10];
          memset(mark,0,sizeof(mark));
          k=0;
          while(input[i]!=' '){
              mark[k]=input[i];
              k++;i++;
          }
          scores[0] = atoi(mark);
         
         
          checknegative(scores[0]);
         
          while(input[i]==' ')
              i++;

          memset(mark,0,sizeof(mark));
          k=0;
          while(input[i]!=' '){
              mark[k]=input[i];
              k++;i++;
          }
          scores[1] = atoi(mark);
         

          checknegative(scores[1]);

          while(input[i]==' ')
              i++;
          memset(mark,0,sizeof(mark));
          k=0;
          while(input[i]!=' '){
              mark[k]=input[i];
              k++;i++;
          }
          scores[2] = atoi(mark);
          
          checknegative(scores[2]);

         
          while(input[i]==' ')
              i++;
          memset(mark,0,sizeof(mark));
          k=0;
          while(input[i]!=' '){
              mark[k]=input[i];
              k++;i++;
          }
          scores[3] = atoi(mark);
         
          checknegative(scores[3]);
         


         
          while(input[i]==' ')
              i++;
          memset(mark,0,sizeof(mark));
          k=0;
          while(input[i]!=' '){
              mark[k]=input[i];
              k++;i++;
          }
          scores[4] = atoi(mark);
         
          checknegative(scores[4]);
     


         
          while(input[i]==' ')
              i++;
          if(input[i]==''){
              cout<<"WARNING: only 5 scores present for "<<firstname[j]<<" "<<lastname[j]<<endl;
             
              getaverage(avg_score,j,scores,-1);
              j++;
              continue;


          }         
          memset(mark,0,sizeof(mark));
          k=0;
          while(input[i]!=' '){
              mark[k]=input[i];
              k++;i++;
          }
          scores[5] = atoi(mark);
         

          checknegative(scores[5]);
          int min_grade = getmingrade(scores,6);
     
          getaverage(avg_score,j,scores,min_grade);
          j++;
         
          while(input[i]!='')
              i++;
         

      }
   }

   cout<<" last_name First_name ID avgerage_score Grade"<<endl;
   for(int index=0;index<j;index++){
       cout<<lastname[index]<<" ";
       cout<<firstname[index]<<" ";
       cout<<id_char[index]<<" ";
       cout<<avg_score[index]<<" ";
       char grade = get_grade(avg_score[index]);
       cout<<grade<<endl;
       gradetotal[grade-'A']++;
   }

   cout<<" Grade Totals ";

   for(int i=0;i<4;i++)
       if(gradetotal[i]){
           char c = 'A'+i;
           cout<<c<<" = "<<gradetotal[i]<<endl;
       }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote