Problems

advertisement

IB HL Math: Programming Homework

Assigned: 9/6/06 (Wednesday)

Due: 9/11/06 (Monday, email to dmarino@cs.ucf.edu)

1) You are attempting to determine the height of a building (that is more than 5 stories tall) as well as your distance from the building. Here is the information you know: a) The angle of elevation to the fifth story window from your location on the ground. b) The angle of elevation to the top of the building from your location on the ground. c) The distance from the fifth story window to the top of the building.

Write a program that prompts the user for these three pieces of information. Have the user enter the first two measurements in degrees. Your program should output both the height of the building and the distance the user is from the building.

2) You want to write a program that calculates your probability of getting an A on your next math exam. Here's the data you have:

1) Given that you get a good night's rest the night before the test, you have a p% chance of getting an A.

2) Given that you don't get a good night's rest the night before the test, you have a q% chance of getting an A.

3) You have a r% chance of getting a good night's rest on any given night.

Given this data, your job is to calculate your chance of getting an A. If this probability is above 50%, print out the message:

You will most likely get an A!

Otherwise, if this probability is below 50% print out the message

You will most likely not get an A.

If the probability is exactly 50% that you will get an A, print out:

You have a perfectly fair chance of getting an A.

In a separate line of output, print out your chance of getting an A.

Your program should prompt the user for the three pieces of information shown above, and then make the necessary calculation, output the chance the user will get an A, followed by one of the three messages shown above.

Here is a sample run for each program:

Program #1

What is the angle of elevation in degrees to the 5th story?

30

What is the angle of elevation in degrees to the top story?

45

What is the distance between the 5th and top story?

84.529946

The height of the building is 200.0 feet.

The distance from the observer to the building is 200.0 feet.

Program #2

Given a good night's rest, what percent chance do you have of getting an A?

75

Given not getting a good night's rest, what percent chance do you have of getting an A?

25

What is your chance of getting a good night's rest?

50

You have a 50.0% chance of getting an A.

You have a perfectly fair chance of getting an A.

(Note: It's okay if your program doesn't print out the same number of decimal places as shown on this sample.)

Download