Question

In: Computer Science

in C++ (Please do steps 1-11) 1 ) Create a file that contains your grades and...

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

Solutions

Expert Solution

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 :)


Related Solutions

Create a C++ program that will accept any number of grades for an exam. The grades...
Create a C++ program that will accept any number of grades for an exam. The grades will be input as 4 for an A, 3 for a B, 2 for a C, 1 for a D, and 0 for an F. After all grades have been entered, allow the user to enter -1 to exit. Output the number of grades in each category. Using arrays.
IN C LANGUAGE ONLY PLEASE! First Program: create branchloop.c file Content of the program Enter your...
IN C LANGUAGE ONLY PLEASE! First Program: create branchloop.c file Content of the program Enter your name while running your program as you did with hello2.c (using argc and argv) name has to be 2 words max (e.g. Jose Lopez, Maria Rodrigues) . Make sure to check properly. Print your name 10 times using a loop. 10 is a fixed number. Count how many characters are in your first name and last name. If the number of characters of your...
Please do this in C++ Objective: Create an Inheritance Hierarchy to Demonstrate Polymorphic Behavior 1. Create...
Please do this in C++ Objective: Create an Inheritance Hierarchy to Demonstrate Polymorphic Behavior 1. Create a Rectangle 2. Class Derive a Square Class from the Rectangle Class 3. Derive a Right Triangle Class from the Rectangle Class 4. Create a Circle Class 5. Create a Sphere Class 6. Create a Prism Class 7. Define any other classes necessary to implement a solution 8. Define a Program Driver Class for Demonstration (Create a Container to hold objects of the types...
Write a C++ program to create a text file. Your file should contain the following text:...
Write a C++ program to create a text file. Your file should contain the following text: Batch files are text files created by programmer. The file is written in notepad. Creating a text file and writing to it by using fstream: to write to a file, you need to open thew file as write mode. To do so, include a header filr to your program. Create an object of type fsrteam. Open the file as write mode. Reading from a...
IN PYTHON PLEASE Create a file lists.py that contains the following functions: sumOfOdd(intList) The parameter intList...
IN PYTHON PLEASE Create a file lists.py that contains the following functions: sumOfOdd(intList) The parameter intList is supposed to be a list of integers. The function returns the sum (addition) of the odd integers from intList, and leaves intList not modified For instance, given [1,2,3,4], the function returns 4. The function performs no I/O. productOfEven(intList) The parameter intList is supposed to be a list of integers. The function returns the product (multiplication) of the even integers from intList, and leaves...
How to do in C++ HTML Converter Create a program that reads an HTML file and...
How to do in C++ HTML Converter Create a program that reads an HTML file and converts it to plain text. Console HTML Converter Grocery List * Eggs * Milk * Butter Specifications Your instructor should provide an HTML file named groceries.html that contains these HTML tags: <h1>Grocery List</h1> <ul>     <li>Eggs</li>     <li>Milk</li>     <li>Butter</li> </ul> When the program starts, it should read the contents of the file, remove the HTML tags, remove any spaces to the left of the tags, add...
Create a Python program that: Reads the content of a file (Vehlist.txt) The file contains matching...
Create a Python program that: Reads the content of a file (Vehlist.txt) The file contains matching pairs of vehicle models and their respective makes Separate out the individual make and model on each line of the file Add the vehicle make to one list, and the vehicle model to another list; such that they are in the same relative position in each list Prompt the user to enter a vehicle model Search the list containing the vehicle models for a...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of the word. Next, use the struct to store the word read from a text file call “word.txt” and the length of the word. Print out the word x number of times based on the length of the word as shown below. Also, print a statement with the length and determine if the string length has an odd number or even number of characters. You...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a...
JAVASCRIPT: - Please create an object (grade) with 10 names and 10 grades. - Create a method (inputGrade) that can put a name and a grade to the grade object. - Create another method (showAlltheGrades) to show all the grade in that object. - Create the third method (MaxGrade) that can display the maximum grade and the student name. - Using “prompt” and inputGrade method input 10 student names and their grades. - Display all the grades and names by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT