ication is 1 and 1 to sophomore counter if classification is not 1.
5-3. Construct an if-then-else that prints the message Data item out of range when the value of the data item is less than zero or greater than 1,000.
(Notice that this if then-else has a null case.)
5-4. Construct an if-then-else that adds 1 to resident counter if state of residence is Arkansas and adds 1 to nonresident counter otherwise.
EXPANDED TEMPERATURE CONVERSION PROBLEM
We have used the temperature conversion problem for illustrating arithmetic and looping. Degrees Fahrenheit were converted into degrees centigrade. Now consider the problem of converting either from degrees Fahrenheit to degrees centigrade or from degrees centigrade to degrees Fahrenheit. The formulas for conversion are
Statement of problem: The input record contains a temperature followed by its units, F or C. Construct a computer program that will read a temperature, with its units, from the input record and print both the temperature read and the equivalent temperature with its units.
The solution clearly involves selection. The units read from the input record must be tested, and one of two alternatives must be taken, depending upon the units. One solution is shown in IPO Diagram 5-1. Notice that the selection group corresponds to the general form. The then and else cases are indented; each stands out clearly and is distinct from the other.
Figure 5-5 shows a flowchart for the temperature conversion problem.
Temperature with units C or F. Declare numeric T, F, C Declare character U.1. Read temperature T and units, U2. Print T and U. 3. if U is 'F', then C = (5 * (F - 32))/9. Print T,' deg. F' and C, ' deg. C'. Else F = 32 + (9 * C) 5 Print T, ' deg. C' and F, ' deg. F'. End if.4. Stop. Input temperature T with units, and equivalent temperature with units(C to F or F to C)....