Chapter 5: Programming Projects
1. Let's suppose we want to print out a chart showing how
the time it takes to fly from one city to another
varies with the speed at which we fly. The formula is
Distance = Speed * Time.
Let`s limit the speed to the range falling between 100
mph and 1000 mph, in increments of 100 mph, therefore
the formula you will use is
Time = Distance / Speed.
You will write a program that will accept the name of
the city where the trip is to start, the name of the
destination city, the distance from the start city to
the destination city, the beginning speed to start the
calculation with, and the ending speed of the
calculations. Your output will have the following
format:
Distance from to
is
Rate(mph) Time(hours)
=========== =============
When the chart has been printed, ask if the user wishes
to continue, if so, then go back and ask for new input.
2. Write a program to output an ASCII chart like the one
below. The program is to show a screen full of
information and then pause displaying
More(Y/N)?. If the user wishes to see the next
screen, he/she presses Y, to terminate the program
press N. The program must be sensitive to those
characters represented by decimal values 0-31. These
are control characters and when sent to a terminal can
cause the terminal to lock up. Therefore, the actual
character or the hexadecimal or the decimal value must
not be sent to the terminal, but only a string of
characters representing the image of the decimal,
hexadecimal and display character.
DEC HEX CHAR DEC HEX CHAR
0 00 ^@ NUL 64 40 @
1 01 ^A SOH 65 41 A
2 02 ^B STX 66 42 B
3 03 ^C ETX 67 43 C
4 04 ^D EOT 68 44 D
5 05 ^E ENQ 69 45 E
6 06 ^F ACK 70 46 F
7 07 ^G BEL 71 47 G
8 08 ^H BS 72 48 H
9 09 ^I HT 73 49 I
10 0A ^J LF 74 4A J
...
3. Develop a program that will determine the gross pay for
each of several employees. The company pays "straight-
time" for the first 40 hours worked by each employee
and pays "time-and-a-half" for all hours worked in
excess of 40 hours. You are to input a maximum of 6
employees. Do not use if statements or a switch
statement, but use only loops. The regular hours must
not exceed 40. You must handle the input of employee
number, last name, first name, regular hours worked,
overtime worked, and pay rate. After inputing all
values, then compute the net pay using 15% as the
deduction amount. After all 6 employees are input,
then print totals for regular hours worked, overtime
hours worked, gross pay, total deductions and net pay.