0% found this document useful (0 votes)
13 views2 pages

PSPD_Lab Assignment 2

Uploaded by

jayantip837
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

PSPD_Lab Assignment 2

Uploaded by

jayantip837
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab Assignment-2

2. Programming project on Selection Structures: if and switch statements

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.

Operation White Bread Sweet Bread


Primary kneading 15 mins 20 mins
Primary rising 60 mins 60 mins
Secondary kneading 18 mins 33 mins
Secondary rising 20 mins 30 mins
Loaf shaping 2 seconds 2 seconds
Final rising 75 mins 75 mins
Baking 45 mins 35 mins
Cooling 30 mins 30 mins

2.3 Write a program that interacts with the user like this:

(1) Carbon monoxide


(2) Hydrocarbons
(3) Nitrogen oxides
(4) Nonmethane hydrocarbons
Enter pollutant number: 2
Enter number of grams emitted per mile: 0.35
Enter odometer reading: 40112
Emissions exceed permitted level of 0.31 grams/mile.

Use the table of emissions limits below to determine the appropriate message.

First 50,000 Miles Second 50,000 Miles


carbon monoxide 3.4 grams/mile 4.2 grams/mile
hydrocarbons 0.31 grams/mile 0.39 grams/mile
nitrogen oxides 0.4 grams/mile 0.5 grams/mile
nonmethane hydrocarbons 0.25 grams/mile 0.31 grams/mile

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.

You might also like