Question 1 What is the screen output of the following code s

Question 1

What is the screen output of the following code segment?

Explain the reasoning behind your answer.

#include <iostream>

using namespace std;

int main()

{

    double Test1 = 70;

    double Test2 = 80;

    double Test3 = 84;

    double Average = 0;

    int NumberOfTests = 3;

    Average = (Test1 + Test2 + Test3) / NumberOfTests;

    if (Average >= 90)

    {

        cout << \"Great job\";

        cout << \"Your average is: \" << Average;

    }

    else if (Average >= 80 || Average <=89)

    {

        cout << \"Nice work\";

        cout << \"Your average is: \" << Average;

    }

    else

    {

        cout << \"Your average is: \" << Average;

        cout << \"You will do better next time!\";

    }

    return 0;

}

Question 2

Explain the properties and limitations of integer and floating-point numbers.

Question 3

Explain nested branches and loops.

Question 4

Explain the fundamental principles of testing and debugging.

Question 5

Design a class named EmployeeRecord that holds an employee’s ID number, name, and payrate. Include mutator methods to set the values for each data field and output the values for each data field. Create the class diagram and write the code that defines the class and implements the mutator methods.

Solution

Hi, I have answered first two questions.

Please post other questions in separate post.

Q1)

it executes second block:

else if (Average >= 80 || Average <=89)

    {

        cout << \"Nice work\";

        cout << \"Your average is: \" << Average;

    }

Average >= 80 : evaluates to fasle because Average < 80 (78)
Average <=89 : evaluates to true because 78 <= 89

So, false || true => true

Output:
Nice workYour average is: 78

Q2)

Integer:
- represent integeral values
- vaery fast computation on integers variables
- can represent lesser data range
- With integer types, you cannot easily express fractional or decimal values outside the integer set

Floating:
- can represent floating point numbers
- compratively larger range as compare to integer type
- floating point operations usually are slightly slower than integer operations, and you can lose precision.
- Floating-point variables can’t be used to count things, are more difficult for the computer to handle, and also suffer from round-off error (though not nearly to the same degree as int variables).

Question 1 What is the screen output of the following code segment? Explain the reasoning behind your answer. #include <iostream> using namespace std; int
Question 1 What is the screen output of the following code segment? Explain the reasoning behind your answer. #include <iostream> using namespace std; int

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site