Homework Programs


Calculation Problems (Topics from Chapter 2)

1.  The common field cricket chirps in direct proportion to the current tem­perature. Adding 40 to the number of times a cricket chirps in a minute, then dividing by 4, gives us the temperature (in Fahrenheit degrees). Write a program that accepts as input the number of cricket chirps in fifteen seconds, then outputs the current temperature to the nearest half degree.

2. Write a program that gauges inflation. It should accept two prices (in whole dollars) as input and print their difference, as well as the percentage increase to two decimal places. Then accept as input the number of weeks between the two prices, and compute the yearly rate of inflation (as percentage increase).



Ch 3 Problems

8. Write a program that will perform some calculations regarding a cyclist coasting on a level road. The input to the program will be the cyclist's initial speed (in miles/hour), the duration (in minutes), and the final speed. The rate of acceleration can be computed using the formula:

a
= (Vfinal -Vinitial) / duration

Write a function to implement this equation to compute acceleration given the initial and final speed and the duration. Call this function and display the cyclist's rate of acceleration (in this case, it's negative).
Next, write another function that will determine how long it will take for the cyclist to come to rest (given the inital speed and the calculated acceleration.) The necessary formula is:

time -Vinitial / a

Call this function and display the result.
Test your program using values of 10 for initial speed, 2.5 for final speed, and 1 minute for duration.