Question

In: Computer Science

Find the errors in following program. //This program averages three test scores. //It uses variable perfectScore...

Find the errors in following program.


//This program averages three test scores.


//It uses variable perfectScore as a flag.


#include <iostream>

uisng namespace std;


int main()


{

cout<<"Enter your three 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";

return 0;


}

Solutions

Expert Solution

//This program averages three test scores.
//It uses variable perfectScore as a flag.
#include <iostream>

using namespace std;    // It's using here

int main() {
    cout << "Enter your three test scores and I will"  // remove ; here
         << " average them: ";
    int score1, score2, score3; // use ; here
    cin >> score1 >> score2 >> score3;
    double average;
    average = (score1 + score2 + score3) / 3.0;
    bool perfectScore = false;  // declare perfectScore before using it here.
    if (average == 100)  //  remove ; here and use == for comparison
        perfectScore = true; // set the flag variable
    cout << "Your average is " << average << endl;
    if (perfectScore)
    {
        cout << "Congratulations!\n";
        cout << "That's a perfect score.\n";
    }
    return 0;   // return here at the end of main
}   // close using }

Related Solutions

Consider the following program. // This program averages 3 test scores. It repeats as // many...
Consider the following program. // This program averages 3 test scores. It repeats as // many times as the user wishes. #include <iostream> using namespace std; int main() { int score1, score2, score3; // Three scores double average; // Average score char again; // To hold Y or N input do { // Get three scores. cout << "Enter 3 scores and I will average them: "; cin >> score1 >> score2 >> score3; // Calculate and display the average....
Write a program that will find the class average of fifteen (15) test scores for five...
Write a program that will find the class average of fifteen (15) test scores for five (5) different tests. The class average must be stored into an integer array. You are to have three separate arrays: Note: _jd represents the initials of the programmer. Your array and function names should be named by replace the initials jd with your first and last initials Arrays Student Names Scores Averages Name of array students_jd scores_jd averages_jd Size of array [15][10] [15][5] .[5]...
Find the following probabilities for test scores X, for which the mean is 400 and the...
Find the following probabilities for test scores X, for which the mean is 400 and the standard deviation is 120. Assume that the test scores are described by a normal curve. (Round all answers to four decimal places.) (a) P(X ≤ 400). (b) P(X ≤ 580). (c) P(X ≥ 640). (d) P(400 ≤ X ≤ 640).
C++ : Find the syntax errors in the following program. For each syntax error, fix it...
C++ : Find the syntax errors in the following program. For each syntax error, fix it and add a comment at the end of the line explaining what the error was. #include <iostream> #include <cmath> using namespace std; int main(){ Double a, b, c; 2=b; cout<<"Enter length of hypotenuse"<<endl; cin>>c>>endl; cout>>"Enter length of a side"<<endl; cin>>a; double intermediate = pow(c, 2)-pow(a, 2); b = sqrt(intermediate); cout<<"Length of other side is:" b<<endline; return 0; }
Java program Test Scores? Design a TestScore class that has three integer fields, each holding a...
Java program Test Scores? Design a TestScore class that has three integer fields, each holding a test score. The class should have accessor and mutator methods for the test score fields and a method that returns the average of the test scores as a double. Test the TestScore class by writing a separate program that creates an instance of the class. The program should ask the user to enter three test scores, which should be stored in the TestScore object....
Detect the errors in the following program? How many errors do you observe in the following...
Detect the errors in the following program? How many errors do you observe in the following line of code? Clearly explain what these errors are and how they can be fixed? (Note that this program has only three lines of code). Please type your program in the following textbox. for i in Range(1,20.0): if i%2=0: print(i) This is a python program
The following code segment which uses pointers may contain logic and syntax errors. Find and correct...
The following code segment which uses pointers may contain logic and syntax errors. Find and correct them. a) Returns the sum of all the elements in summands int sum(int* values) { int sum = 0; for (int i = 0; i < sizeof(values); i++) sum += *(values + i); return sum; } b) Overwrites an input string src with "61C is awesome!" if there's room. Does nothing if there is not. Assume that length correctly represents the length of src....
Write a C program that has a local and a global variable. The program uses a...
Write a C program that has a local and a global variable. The program uses a fork to create a child process. The parent process modifies both variables to be 10 and 20 and prints out the values. Then the child process modifies both variables to be 100 and 200 and prints out the values? Explain the program output?
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
Write a program that asks the user to enter five test scores. The program should display...
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT