I'm trying to write a script asking people if a test was too hard or not. I'm new, and I'm not very good with the "if" "else" thing yet. This is my code so far... please help out in any way possible! I greatly appreciate it!! I need it to say if the test is too easy, the class average would be above a 90%. If it was too hard, it would be below a 70%.
#include <iostream>
usingnamespace std;
int main()
{
cout << "Was the test too hard? Let's Find out." << endl;
//Determine if Test is too easy for Class
if (test > 90)
{
if (test >= 90)
{
cout << "Test was too easy." << endl;
}
return 0;
}
1. creat an integer variable called test.
2. use cin to type in a value for test
3. use cout to prompt user to 'type in the class average'
4. if test > 90 cout 'test was too easy' else if test <70 cout 'test was too hard'
Thank you! I've edited it a bit, but now I need to find a way to make sure that the entire class, once the input is collected, how to get the class average.
// This program gets a numeric test score from the
// user and displays the corresponding letter grade.
#include <iostream>
using namespace std;
int main()
{
int testScore;
// Get the Test Score.
cout << "Enter your test score: ";
cin >> testScore;
// Determine the letter grade.
if (testScore >=90)
cout << "Test was too easy, but you got an A." <<endl;
else if (testScore >= 80)
cout << "Your grade is a B." << endl;
else if (testScore >= 70)
cout << "Your grade is a C." << endl;
else if (testScore >= 60)
cout << "Your grade is a D." << endl;
else
cout << "Your grade is an F." <<endl;
So, forgetting how to write the C++ code what steps would you take to get the average. What is the average? Could you use an array to store each students result? Would a loop of some sort be required?
Maybe if it's just the average you can just add up the results and count the number of students as you go and do away with the idea of an array.
You've done it for one person so you can loop through the same stuff for everybody ... What's included in the loop of the lines above and what extra lines do yo need?