CS100 M Spring 2005
Review/Practice Questions for Prelim 1

Question 1
The income tax code in Timbuktu works as follows: the first $30,000 of income is taxed at 25%, the next $30,000 at 30%, and any amount above $60,000 at 40%. Write a program that accepts as input an income amount and computes and prints the correct tax amount to be paid in Timbuktu.

Question 2
Write a program that accepts three numbers as input and prints the maximum of the three numbers. Do not use arrays. The only MATLAB built-in function allowed is input.

Question 3
Write a MATLAB program fragment to print all integers between 1 and 1000, inclusive, that are divisable by 2 and 5 but not by 7.

Question 4
Write a MATLAB script to simulate coin tossing: print "H" for heads and "T" for tails. The simulation cointinues until the first run of 6 heads occurs. Print the total number of coin tosses in the simulation.

Question 5
Write a script that reads in a time in seconds and prints the equivalent value in hours:minutes:seconds.

Other review questions
Be sure to review the examples from lecture, the exercises in section (and lab), and the projects.