Hello all,
Currently I am working out of "Problem Solving with C++ Tenth Edition" to prepare for next semester and am working on the current problem.
"In an exam, students are given a set of questions and 1 point is awarded for every correct answer and 0.25 points are deducted for every incorrect answer. Write a program that prompts the user for the number of questions that the student answered correctly and the number of incorrect answers. The program should use a function calcMarkAsPercentage to calculate the student’s final mark as a percentage. Carefully consider the order of operations required to calculate the correct score and if you need to cast any values"
To do this part I wrote this code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
double calcMarkAsPercentage(int QRight, int QWrong);
//Calculate grade percentage based off of questions answered rigth and questions answered wrong.
int main()
{
int QRight, QWrong;
std::cout << "Please input the number of questions answered correctly.\n";
std::cin >> QRight;
std::cout << "You have entered: " << QRight << " correct answers.\n";
std::cout << "Please input the number of questions answered wrong.\n";
std::cin >> QWrong;
std::cout << "You have entered: " << QWrong << " wrong answers.\n";
double PercentageGrade = calcMarkAsPercentage(QRight, QWrong);
std::cout << "The total amount of points possible is: " << (QRight + QWrong) << " points.\n";
std::cout << "The total amount of points scored is: " << ((QRight * 1) + (QWrong * -0.25)) << " points.\n";
std::cout << "The score for this exam is: " << PercentageGrade << "%";
}
double calcMarkAsPercentage(int QRight, int QWrong)
{
//TotalQ is also Total Points
int TotalQ = QRight + QWrong;
//Sum of right points and wrong points converted to percentage
double PercentageGrade = (((QRight * 1) + (QWrong * -0.25)) / TotalQ) * 100;
return PercentageGrade;
}
| |
However, the next part of the problem is as follows.
"Modify your program from the previous Practice Program to ask the user for the number of students whose marks are to be entered. Your program should then prompt the user for the marks of the required number of students. If a student gets a score lower than 0, their mark should be set to and output as 0. Your program should then print the highest, lowest, and average score of the students whose scores were calculated."
With a little research, I found people bringing up Array's which is a topic not yet discussed in the book, and I am trying to use what I have learned so far which is the basics of variables, flow of control, and function declarations. Any insight would be greatly appreciated!