// This program averages 3 test scores.
// It uses the variable perfectScore as a flag. include <iostream>
using namespace std;
int main() {
cout << "Enter your 3 test scores and I will "; << "average them:";
int score1, score2, score3,
cin >> score1 >> score2 >> score3;
double average;
average = (score1 + score2 + score3) / 3.0; if (average = 100);
perfectScore = true; // Set the flag variable cout << "Your average is " << average << endl; bool perfectScore;
if (perfectScore);
{
cout << "Congratulations!\n";
cout << "That's a perfect score.\n";
cout << "You deserve a pat on the back!\n"; return 0;
}
I stopped looking after finding 8. I think the problem should be, "Please help me find 5 correct programming lines in this program". THAT would be a better search.
#include <iostream>
// This program averages 3 test scores.
// It uses the variable perfectScore as a flag. include <iostream>
usingnamespace std;
int main()
{
cout << "Enter your 3 test scores and I will average them: \n";
double score1, score2, score3;
cin >> score1 >> score2 >> score3;
double average = 0;
average = (score1 + score2 + score3) / 3.0;
cout << "Your average is " << average << '\n';
if (average == 100)
{
cout << "Congratulations! \n";
cout << "That's a perfect score.\n";
cout << "You deserve a pat on the back!\n";
}
return 0;
}
The best way I can think of right now, and forgive me cause I am suffering from the flu is an if/else statement. Please remember if you are using this for school work that you should try to go back to the book and your class mates as well. Also if you are going to us an IDE, you may need to pause the program.
#include <iostream>
// This program averages 3 test scores.
// It uses the variable perfectScore as a flag. include <iostream>
usingnamespace std;
int main()
{
cout << "Enter your 3 test scores and I will average them: \n";
double score1, score2, score3;
cin >> score1 >> score2 >> score3;
double average = 0;
average = (score1 + score2 + score3) / 3.0;
bool perfectScore = false;
if (average==100)
{
perfectScore = true;
}
cout << "Your average is " << average << '\n';
if (perfectScore == true)
{
cout << "Congratulations! \n";
cout << "That's a perfect score.\n";
cout << "You deserve a pat on the back!\n";
return 0;
}
else
{
cout << "Sorry, you did not achive a perfect score.\n";
return 0;
}
}