Question

In: Computer Science

Imagine you are a student enrolled in a College course where the course grade is calculated...

Imagine you are a student enrolled in a College course where the course grade is calculated using a weighted average. (It might not be too hard to imagine.) It’s nearing the midterm of the semester and you want to know what your grade is. Luckily, your professor has provided you with a syllabus, and in that syllabus he or she has listed the formula for calculating your course grade. (This is sounding more familiar all the time.)

Graded Activity Percentage

Exams are 30%

Projects are 30%

Assignments are 15%

Quizzes are 5%

You will notice that the weighted percentages only add up to 80% of the total grade. That’s because the final exam will represent the last 20% of your grade. That said, let’s calculate our current grade with only the grades we have SO FAR, and ignoring the final exam part. You want to write a program that asks you for all of your grades, one graded activity at a time, one grade at a time. (See the SAMPLE RUNS section below.)

You need to write a program that does this making use of the following functions:

void printPrompt(int a)

– This function accepts a single incoming integer (value 1 through 4). Depending on the value of the incoming integer the function prints out the prompt to enter grades of a certain type (quiz grades, assignment grades, exam grades, and project grades) and tells the user to enter -1 to quit. This function is only responsible for printing the prompt and accepts NO user input. It also returns nothing.

double average()

– This function takes no incoming data (no parameters), but it does receive input from the user through cin. The user enters a series of integer grades with a -1 to terminate input. It also calculates the average of all inputs entered. This average is returned as a double.

double weightedAverage(double, double, double, double)

– This function takes in four double values which represent the averages of the four types of graded activity. It calculates and returns the current weighted average, in the form of a double.

void outputAverages(double, double, double, double, double)

– This function accepts five double values: the four graded activity averages calculated before, as well as the overall weighted average. The function prints out the average of each type of grade; quiz average, assignment average, exam average, and project average, as well as the current grade in the course. It has no outgoing data (no return values).

PROVIDED SKELETON CODE:

For this assignment we have provided part of your solution for you. Specifically, we have provided a file where we have listed all the necessary function declarations as well as a main function that makes calls to these functions. DO NOT MODIFY either the function declarations OR the main function.

Your job will be to add the function definitions below the main function. A completed and

fully functional program should result if you correctly define these functions.

SAMPLE RUNS:

Sample Run 1:

Enter your quiz grades (-1 to end input):

100 95 90 85 -1

Enter your assignment grades (-1 to end input):

50 100 100 25 0 -1

Enter your exam grades (-1 to end input):

65 -1

Enter your project grades (-1 to end input):

80 93 75 -1

Your quiz average: 92.5

Your assignment average: 55

Your exam average: 65

Your project average: 82.6667

Your current grade in this course is: 71.4687

SKELETON (DO NOT MODIFY THE MAIN)

#include <iostream>

using namespace std;

//FUNCTION DECLARATIONS - ***DO NOT MODIFY***

/*name: printPrompt

INCOMING: An integer of possible values 1 through 4 indicating a specific graded

activity

OUTGOING: None

*/

void printPrompt(int);

/*name: average

INCOMING: None

OUTGOING: The double average of the integer grades as entered by the user

*/

double average();

/*name: weightedAverage

INCOMING: Four double values representing the averages for the four graded

activities

OUTGOING: The double value representing the weighted average for the course so

far (a.k.a. the current grade)

*/

double weightedAverage(double, double, double, double);

/*name: outputAverages

INCOMING: A double value representing the current grade and four double values

for four graded activity averages

OUTGOING: None

*/

void outputAverages(double, double, double, double, double);

//MAIN FUNCTION - ***DO NOT MODIFY***

int main(){

double quizAvg, assignAvg, examAvg, projAvg, currentGrade;

int count = 1;

while (count<=4){

printPrompt(count);

switch(count){

case 1:

//1 - getting the quiz grades

quizAvg = average();

break;

case 2:

//2 - getting the assignment grades

assignAvg = average();

break;

case 3:

//3 - getting exam grades

examAvg = average();

break;

case 4:

//4 - getting project grades

projAvg = average();

break;

}

  count++;

}

//get the current grade, based on the different averages and their weights.

currentGrade = weightedAverage(quizAvg, assignAvg, examAvg, projAvg);

outputAverages(currentGrade, quizAvg, assignAvg, examAvg, projAvg);

}

//END MAIN FUNCTION

//**--YOUR WORK HERE--**

//**PLACE YOUR FUNCTION DEFINITIONS (a.k.a. IMPLEMENTATIONS) BELOW**

Solutions

Expert Solution

Note: Done accordingly. Please comment for any problem. Please Uprate. Thanks.

Code:

#include <iostream>

using namespace std;

//FUNCTION DECLARATIONS - ***DO NOT MODIFY***

/*name: printPrompt

INCOMING: An integer of possible values 1 through 4 indicating a specific graded

activity

OUTGOING: None

*/

void printPrompt(int);

/*name: average

INCOMING: None

OUTGOING: The double average of the integer grades as entered by the user

*/

double average();

/*name: weightedAverage

INCOMING: Four double values representing the averages for the four graded

activities

OUTGOING: The double value representing the weighted average for the course so

far (a.k.a. the current grade)

*/

double weightedAverage(double, double, double, double);

/*name: outputAverages

INCOMING: A double value representing the current grade and four double values

for four graded activity averages

OUTGOING: None

*/

void outputAverages(double, double, double, double, double);

//MAIN FUNCTION - ***DO NOT MODIFY***

int main(){

   double quizAvg, assignAvg, examAvg, projAvg, currentGrade;

   int count = 1;

   while (count<=4){

       printPrompt(count);

       switch(count){

       case 1:

           //1 - getting the quiz grades

           quizAvg = average();

           break;

       case 2:

           //2 - getting the assignment grades

           assignAvg = average();

           break;

       case 3:

           //3 - getting exam grades

           examAvg = average();

           break;

       case 4:

           //4 - getting project grades

           projAvg = average();

           break;

       }

       count++;

   }

   //get the current grade, based on the different averages and their weights.

   currentGrade = weightedAverage(quizAvg, assignAvg, examAvg, projAvg);

   outputAverages(currentGrade, quizAvg, assignAvg, examAvg, projAvg);

   system("pause");
}

double average(){
   double sum=0,count=0,inp;
   while(true){
       cin>>inp;
       if(inp==-1)
           break;
       count++;
       sum=sum+inp;
   }
   return sum/count;
}

void printPrompt(int choice){
   switch (choice)
   {
   case 1:
       cout<<"Enter your quiz grades (-1 to end input):"<<endl;
       break;
   case 2:
       cout<<"Enter your assignment grades (-1 to end input):"<<endl;
       break;
   case 3:
       cout<<"Enter your exam grades (-1 to end input):"<<endl;
       break;
   case 4:
       cout<<"Enter your project grades (-1 to end input):"<<endl;
       break;
   default:
       cout<<"Invalid Input"<<endl;
   }
}

double weightedAverage(double quizzes, double assignments, double exams, double projects){
   return ((30*exams)+(30*projects)+(15*assignments)+(5*quizzes))/80.0;
}

void outputAverages(double weightedAverage, double quizzes, double assignments, double exams, double projects)
{
   cout<<"Your quiz average: "<<quizzes<<endl;

   cout<<"Your assignment average: "<<assignments<<endl;

   cout<<"Your exam average: "<<exams<<endl;

   cout<<"Your project average: "<<projects<<endl;
   cout<<"Your current grade in this course is: "<<weightedAverage<<endl;
}

Output:


Related Solutions

You are taking a college course where your overall average grade is calculated by averaging three...
You are taking a college course where your overall average grade is calculated by averaging three exxam (weighted 20% each), the average of four quizzes (weighted a total of 15%), and a comprehensive final (weighted 25%). Your scores were: 100% on Quiz 1, 80% on Quiz 2, 90% on Quiz 3, 100% on Quiz 4, 90% on Exxam 1, 90% on Exxam 2, 85% on Exxam 3. You have not yet taken the Finall Exxam and don’t have any time...
Chris is enrolled in a college algebra course and earned a score of 260 on a...
Chris is enrolled in a college algebra course and earned a score of 260 on a math placement test that was given on the first day of class. The instructor looked at two distributions of scores – one is the distribution for all first year college students who took the test, and the other is a distribution for students enrolled in this algebra class. Both are approximately normal and have the same mean, but the distribution for the algebra class...
"Imagine that you are the director of student affairs at a small liberal arts college in...
"Imagine that you are the director of student affairs at a small liberal arts college in the Midwest. During a staff meeting, the president of the college shares a number of complaints. The complaints allege that many LGBT students encounter prejudice and discrimination both on campus and among townspeople. The students feel that these problems are college-wide and need to be addressed by the president and her staff as well as by community leaders. The president asks you to create...
Imagine you were shown prior student feedback on the course and one comment was “I am...
Imagine you were shown prior student feedback on the course and one comment was “I am doing Business major X, why do I have to do a statistics course? It is not relevant”. Unfortunately, you do not know which major, X the student was referring to. Select the number of Business Majors at RMIT equal to the number of people in your group and illustrate an example of a simple or multiple regression model relevant to each of the selected...
There are 2567 students enrolled at a small college, with 2053 of them enrolled in a...
There are 2567 students enrolled at a small college, with 2053 of them enrolled in a sociology course. In the sampling distribution of sample proportions of size 230, above what proportion will 52% of all sample proportions be? Select all answers that apply to your calculation below. Use the z-table given below to answer the question: z 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 -0.2 0.421 0.417 0.413 0.409 0.405 0.401 0.397 0.394 0.390 0.386 -0.1 0.460...
I am a student in college right now describe where you want to be with your...
I am a student in college right now describe where you want to be with your life in 10 years A- career, where do you hope to be working ?what education or jobs will you have to comlete to get you there? what recognition do you hope to have achieved? B- financial, how much money will you be making each year? how much money will you be saving each year ? what is the cost of your house? where will...
12. A wonderful, smart student named “SHINY STAR” enrolled in an online college, called “SUBPERB 4-YEAR...
12. A wonderful, smart student named “SHINY STAR” enrolled in an online college, called “SUBPERB 4-YEAR TURN YOUR LIFE INTO A MILLION DOLLARS UNIVERSITY.” When Shiny Star was meeting with his advisor, the advisor told Shiny Star that the college was one of the cheapest colleges around. However, 2 years into his degree, Shiny Star compared prices and realized that other colleges around were much, much cheaper than “SUBPERB 4-YEAR TURN YOUR LIFE INTO A MILLION DOLLARS UNIVERSITY.” Shiny Star...
There are 398 students currently enrolled in a statistics course at your school. You wish to...
There are 398 students currently enrolled in a statistics course at your school. You wish to form a sample of 4 students to answer some survey questions. Select the students who will belong to the simple random sample by using the randomly generated number table below by starting in the fourth row and first column. 35931 89035 23653 46370 28433 62632 81258 40557 19325 43161 28330 34629 79010 22483 95383 12441 20033 11802 03263 75380 Please let me know what...
Imagine you are a potential student, new student, or current student searching for information about a...
Imagine you are a potential student, new student, or current student searching for information about a particular degree program you are interested in pursuing and what you would have to do to complete that degree at a college. With the characteristics of technical communication and measures of excellence in mind, Reply to this discussion with an initial post in which you discuss the effectiveness of the College’s website in helping you resolve this problem ( finding a particular degree program...
How can I persuade other college student to take a business communication course?
How can I persuade other college student to take a business communication course?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT