|
|
 |
|
|
|
|
____________(myinput.dat);
____________myoutput.dat);
____________ >> val1 >> val2 >> val3 >> val4;
____________ << val1 << val2 << val3 << val4 << endl;
return 0;
} |
|
|
|
|
|
|
|
|
9. Use top-down design to write an algorithm for starting the engine of an automobile with a manual transmission. |
|
|
|
|
|
|
|
|
10. Use top-down design to write an algorithm for logging on to your computer system, and entering and running a program. The algorithm should be simple enough for a novice user to follow. |
|
|
|
|
|
|
|
|
11. The quadratic formula is |
|
|
|
 |
|
|
|
|
Use top-down design to write an algorithm to read the three coefficients of a quadratic polynomial from a file (inQuad) and write the two floating point solutions to another file (outQuad). Assume that the discriminant (the portion of the formula inside the square root) is nonnegative. You may use the standard library function sqrt. (Express your solution as pseudocode, not as a C++ program.) |
|
|
|
|
|
|
|
|
1. Write a top-down design and a C++ program to read an invoice number, the quantity ordered, and the unit price (all integers), and compute the total price. The program should write out the invoice number, quantity, unit price, and total price with identifying phrases. Format your program with consistent indentation, and use appropriate comments and meaningful identifiers. If you are using an interactive system, write the program to be run interactively, with informative prompts for each data value. |
|
|
|
|
|
|
|
|
2. How tall is a rainbow? Because of the way in which light is refracted by water droplets, the angle between the level of your eye and the top of a rainbow is always the same. If you know the distance to the rainbow, you can multiply it by the tangent of that angle to find the height of the rainbow. The magic angle is 42.3333333 degrees. The C++ standard library works in radians, however, so you have to convert the angle to radians with this formula: |
|
|
|
 |
|
|
|
|
where p equals 3.14159265. |
|
|
|
 |
|
|
|
|
Through the header file math.h, the C++ standard library provides a tangent function named tan. This is a value-returning function that takes a floating point parameter and returns a floating point result: |
|
|
|
 |
|
|
|
|
x = tan(someAngle); |
|
|
|
 |
|
|
|
|
If you multiply the tangent by the distance to the rainbow, you get the height of the rainbow. |
|
|
|
|
|