PSPD_Lab Assignment 2
PSPD_Lab Assignment 2
2.1 While spending the summer as a surveyor’s assistant, you decide to write a program that
transforms compass headings in degrees (0 to 360) to compass bearings. A compass bearing
consists of three items: the direction you face (north or south), an angle between 0 and 90
degrees, and the direction you turn before walking (east or west). For example, to get the
bearing for a compass heading of 110.0 degrees, you would first face due south (180 degrees)
and then turn 70.0 degrees east (180.0 - 70.0 = 110.0). Therefore, the bearing is South 70.0
degrees East. Be sure to check the input for invalid compass headings.
2.2 Write a program to control a bread machine. Allow the user to input the type of bread as W for
White and S for Sweet. Ask the user if the loaf size is double and if the baking is manual. The
following table details the time chart for the machine for each bread type. Display a statement
for each step. If the loaf size is double, increase the baking time by 50 percent. If baking is
manual, stop after the loaf-shaping cycle and instruct the user to remove the dough for manual
baking. Use functions to display instructions to the user and to compute the baking time.
2.3 Write a program that interacts with the user like this:
Use the table of emissions limits below to determine the appropriate message.
3
2.4 Write a program that determines the day number (1 to 366) in a year for a date that is
provided as input data. As an example, January 1, 1994, is day 1. December 31, 1993, is day
365. December 31, 1996, is day 366, since 1996 is a leap year. A year is a leap year if it is
divisible by four, except that any year divisible by 100 is a leap year only if it is divisible by
400. Your program should accept the month, day, and year as integers. Include a function leap
that returns 1 if called with a leap year, 0 otherwise.