Due Date: midnight, Friday, 14 September.
This assignment focuses on computing with numbers from Chapter 3.
Submit the following programs via Blackboard:
- Write a program that takes a length in yards and returns the number of
miles and yards (recall that there are 1760 yards to a mile). For example, if
the user entered, 2000, your program would output, 1 miles 240 yards.
Note that you should use "miles" and "yards" for all inputs (even
in the cases where it is grammatically incorrect).
- Chapter 3, #4 (lightning strike): write a program that determines the distance
to a lightening strike based on the time elapsed between the flash and the sound
of thunder. The speed of sound is approximately 1100 ft/sec and 1 mile is 5280 ft.
- Write a program that asks the user for a number and then displays a countdown
from that number. That is, starts by displaying that number, then one less,
and continuing until it reaches 1. Here is a sample interaction:
Please enter a number: 5
- Write a program to calculate how much money you would have if your money doubled
every day. Your program should ask the user for the number of days and display
the amount of money for each day. The starting amount of money is $1.
Here is a sample interaction:
Please enter the number of days: 8
Day 1: $1
Day 2: $2
Day 3: $4
Day 4: $8
Day 5: $16
Day 6: $32
Day 7: $64
Day 8: $128
- Chapter 3, #10 (ladder length): write a program to determine the length of a ladder
required to reach a given height when leaned against a house. The height and angle of the ladder
are given as inputs. To compute the length use:
length = height/(sin angle)
Note: the angle must be in radians. Prompt for an angle in degrees and use this
formula to convert:
radians = π*degrees/180
For more information on using Blackboard, see the first
- Two of the five submitted programs will be chosen at random for grading.
- Assignments must be submitted by midnight on the date due.
- Every program should begin with a comment that includes your name and a brief description.
- No credit will be given for a late assignment.
- Extra credit will be awarded for graded programs that are submitted early. If a graded
program is submitted more than 12 hours early (before Friday noon), 1 extra credit point will be awarded. For
graded programs submitted more than 24 hours early (Thursday or earlier), 2 extra credit points will be awarded.
- Before submitting an assignment you are free to ask for help in class
(if your question might be of general interest), during office hours, and
by e-mail. Please take advantage of this.