In: Computer Science
in C++ (Please do steps 1-11)
1 ) Create a file that contains your grades and the type of assement (you can just create the file or write the file in the program)
A = Assignment
E = Extra Credit
L - Lab
Q = Qui
M = Mid
Example:
L 20
L 20
L 20
Q 10
A 18
E 9
Q 10
L 20
Q 10
L 20
Q 10
L 20
M 85
2 ) create 3 float arrays with 12 positions (one array for labs one array for qui and one array for assignments) (should be in main)
3 ) create float variables for extra credit, mid exa, attendance and fina exa (should be in main)
4 ) Read the file and place the assessments in their appropriate arrays or variables (should be in main)
5 ) Calculate the average grade for qui, assignments and labs using the following formula(should be in calculate function)
= <average> = (<sum>/(<number_of_grades>*<possible_points>))*100
6 ) Calculate the mid grade using the following formula (should be in main)
= <mid> = <mid>+<extra_credit>
7 ) Give yourself an average of 100 for attendance and pick a grade for your final (should be in main)
8 ) Print the average grade for each assessment type: (should be in main)
:
Example:
Labs: 100
Qui: 100
Assignments: 90
Mid Exa: 94
Fina Exam: 100
Attendance: 100
9 ) Multiply the average by the assessment percentage (should be in main)
Assessment percentage for each assessment type:
Labs: .15
Qui: .05
Assignments: .15
Mid: .25
Fina: .35
Attendance: .05
10 ) Calculate your fina grade (should be in main)
= <current_grade> = <lab_perecent>+<qui_perecent>+<assignment_perecent>+<mid_perecent>+<fina_perecent>+<attendance_perecent>
11 ) Print your fina grade in the following format: (should be in main)
Current grade:
Example
Current grade: 97
Hi there,
I have completed all the tasks given according to the given instructions.
Code:
#include <bits/stdc++.h>
using namespace std;
float avg(float arr[], int len, string c)
{
   //for different arrays different possible will be
there
   int possible;
   if(c=="L")
       possible=20*len;
   else if(c=="Q")
       possible=10*len;
   else if(c=="A")
       possible=20*len;
   int sum=0;  
   for(int i=0;i<len;i++)
       sum+=arr[i];
   //return average  
   return (float)((float)((sum*1.0)/possible)*100);
}
int main()
{
   float labs[12], qui[12], assignments[12]; //2
   int l=0,q=0,a=0;
   float eCredit, mid_exa, attendance=100, fina_exa=100;
//3,7
   ifstream myfile;
   myfile.open ("grades.txt"); //4
   string word1, word2;
   //read the file
   while(myfile>>word2)
   {
       word1=word2;
       myfile>>word2;
       if(word1=="L")
          
labs[l++]=stoi(word2);
       else if(word1=="Q")
          
qui[q++]=stoi(word2);
       else if(word1=="A")
          
assignments[a++]=stoi(word2);  
       else if(word1=="E")
          
eCredit=stoi(word2);
       else if(word1=="M")
          
mid_exa=stoi(word2);
   }  
   //call functions to calcualte averages
   float q_avg=avg(qui,q,"Q"); //5
   float l_avg=avg(labs,l,"L");
   float a_avg=avg(assignments,a,"A");
  
   //update the mid_exa
   mid_exa+=eCredit; //6
   //show the average grades
   cout<<"\nThe average grades are : \n"; //8
   cout<<"\nLabs: "<<l_avg;
   cout<<"\nQui: "<<q_avg;
   cout<<"\nAssignments: "<<a_avg;
   cout<<"\nMid Exa: "<<mid_exa;
   cout<<"\nFina Exam: "<<fina_exa;
   cout<<"\nAttendance: "<<attendance;
  
   //calculate fina_grade according to each
percentage
   float fina_grade=(float)(l_avg*0.15 + q_avg*0.05 +
a_avg*0.15 + mid_exa*0.25 + fina_exa*0.35 + attendance*0.05);
//9,10
  
   //print fina_grade
   cout<<"\n\nCurrent grade:
"<<fina_grade<<endl; //11
  
   return 0;
}            
          
       
code (screenshot):



Output (screenshot):

Hope you liked the answer. If you have any doubt, do let me know in the comments.
Happy Coding :)