Due in few hours - 9 hours from now
a)Proplem:
1. There are few Chevron needed between the vertical bar and set width that is why the particular code will not work properly
2. In this code, the vertical bar is being used to isolate numbers from other numbers.
3. The second and third field width is being ignored in all lines because the length of the displayed digits is more than 5 including the dot.
4. Precision specification is being used to show only two decimals after the dot.
5. The expected display from above code is as the following;
|
|53.43||534.26||534.00| |
Individual explanation:
|53.43| set width and set precision are used
|534.26| set width is ignored and set precision is used
|534.00| set width is ignored and set precision is used
b)
There are various ways to code or type the formula that was given.
Assign the value of to the variable “pi”.
Assign the values of the minor and major axis to a and b.
The algorithm will be written as the following:
Area= pi * a * b; // where pi represents the value of
c)
Therefore, we can assign the height at which the ladder touches the building to the variable X:
Thus, the height at which the ladder touches the building is 19.923 ft.
Step 1: Analyze the problem (Inputs, Outputs):
There is only one output which is the height at which the ladder touches the building (height).
Step 2: Find a solution (Algorithm):
In this problem we can calculate the height as provided above: ladder-length * sin (angle). However, we have to convert the angle from radian to degrees using the following formula:
height = ladder-length * sin (angle * 3.14159 / 180 )
d)
Step 1: Analyze the problem (Inputs, Outputs):
There are three inputs:
· The mass of the first piston
· The radius of the first piston
· The radius of the second piston
There is only one output, which is the mass of the second piston
Step 2: Find a solution (Algorithm):
The formula to find the is given above, yet we have type it in a way to correspond with C++ coding format as the following:
e)
Step 1: Analyze the problem (Inputs, Outputs):
Inputs: the time in hours (t).
Outputs: the number of bacteria (B).
Step 2: Find a solution (Algorithm):
The formula is provided above; however, it is required in the problem to type it in C++ format and add 0.5 into the calculation to round the result number. Therefore, the algorithm should be as the following:
B = (300000 * pow(e, -0.032 * t)) + 0.5;
Where e is the Euler’s number (2.71828) and t is the time in hours.