Answer:
cout << setprecision(2)<< fixed << number;
Explanation:
The above statement returns 12.35 as output
Though, the statement can be split to multiple statements; but the question requires the use of a cout statement.
The statement starts by setting precision to 2 using setprecision(2)
This is immediately followed by the fixed manipulator;
The essence of the fixed manipulator is to ensure that the number returns 2 digits after the decimal point;
Using only setprecision(2) in the cout statement will on return the 2 digits (12) before the decimal point.
The fixed manipulator is then followed by the variable to be printed.
See code snippet below
<em>#include <iostream> </em>
<em>#include <iomanip>
</em>
<em>using namespace std; </em>
<em>int main() </em>
<em>{ </em>
<em> // Initializing the double value</em>
<em> double number = 12.3456; </em>
<em> //Print result</em>
<em> cout << setprecision(2)<< fixed << number; </em>
<em> return 0; </em>
<em>} </em>
<em />
0,7,0,0
9,9,0,0
7,7,7,7
3,9,0,7
Hope this helps
Answer:
a. Protected
b. Public
Explanation:
There are four acess modifier in Java.
Default: Acessible only within the same package.
Public: Can be acessed by any class.
Private: Acessible only within the class.
For example, you have a class employee and a private method. This method can only be accessed by an object that is an instance of an employee.
Protected: Used in classes that extend each other. For example, a class of employees would extend employee.
So:
a. A class Employee records the name, address, salary, and phone number.
The best acesses modifier is protected. A class may extended employee but have the same arguments(name, adress, salary, phone number), so it should also have acess to the method.
b. An adding method inside of a class BasicMath.
This method can be used in a variety of packages and projects and classes... and there is no important information regarding security. So the best method is public.
The next line is 0___________________________