Problems Appendix

This section lists additional problems to assign to assist in mastering a topic or for additional instruction.

Appendix 1
Using Pseudocode write down the process of changing a flat tire on the side of a road.

Appendix 2
Using Pseudocode write down the process of washing, waxing and cleaning a car.

Appendix 3
The format command performs just that operation.  This command allow us to create the look we would often desire in a finished product.  Some general information that could be applied with this workbook is as follows:

 format "%d is an integer and a float is %f" 5 1.23
 format "Examine the spacing of |%5d|%-d|%-5.5f|%5.5f|" 5 5 1.23 2.123456

Write a program that will allow the user to enter a number.  Control the number of decimal places to show as output back to the user.

Appendix 4
Write a program that will compare 2 numbers entered by the user for == or !=, > or < and >= or <=.

Appendix 5
Write a program to calculate miles per gallon.

Appendix 6
Write a program to calculate distance, based on gallons of gas and the vehicles mpg.

Appendix 7
Write a program to calculate your average mph, based on distance and time.

Appendix 8
Write a program allowing the user to input 3 sides of a triangle.  Determine if the triangle is a right triangle.

Appendix 9
Write a program allowing the user to input of 2 sides of a right triangle.  Determine the length of the 3rd side.

Appendix 10
Write a program that will calculate your wages based on a hourly rate and a number of hours worked.  Consider Uncle Sam.

Appendix 11
Write a program that will convert temperatures between Celsius and Fahrenheit.

Appendix 12
Write a program that will accept a radius and height, to calculate the volume of a cylinder.

Appendix 13
Write a program that will be used by a pit crew to determine how many laps you can go on a tank of gas before a pit for more fuel is required.  The program will accept the tank size in gallons, the average lap speed in mph and the length of the track in miles.  Use the following table for mpg:

1-120mph  5 mpg
121-150mph  4.5mpg
151-200mph  4mpg
200+   3mpg

Appendix 14
Write a program that will be used by a pit crew to determine how many laps a new set of tires will last based on average speed and track size.  Use the following table:

1-120mph  100 miles
121-150mph  90 miles
151-200mph  85 miles
200+   72 miles

Appendix 15
In Assignment 5.14 you have written a program to evaluate a number to a grade.  Modify that assignment to keep a running total of grades of each type, also include a reset button.  Consider using switch for flow control.

Appendix 16
A.  Write a program that will accept a number N from the user, then create N message widgets .  Consider global.

B.  Modify the program to have a button that will destroy the N message widgets.

C.  Modify the program to have a button to hide and unhide the widgets.

Appendix 17
Write a program that will display a message widget in a new toplevel, then close the frame and return to the original frame.

Appendix 18
A.  Write a program to emulate a cash register.  (tax should be an option)

B.  Write a program that will emulate a drive through cash register.

Appendix 19
Write a program that will accept 2 ordered pairs P1(x1,y1) and P2(x2,y2) that will calculate the distance between them.

Appendix 20
Fibonacci numbers are numbers that represent a pattern of the format of f(n)=f(n-1)+f(n-2) where f(0)=0 and f(1)=1.  Some examples would be f(2)=f(1)+f(0)=1+0=1 and f(3)=f(2)+f(1)=1+1=2.

Write a program that will accept a number from the user then perform the fibonacci operation.  Consider recursion.

Appendix 21
A.)  Write a program that will emulate the basic operations of a calculator.

B.)  Add trigonometry features to the calculator.

Appendix 22
Arrays are a means to store a list of information.  For example, if you wanted a list of prime numbers for quick reference you could refer to it as follows:

set prime(0) 2
set prime(1) 3
set prime(2) 5
set prime(3) 7
set prime(4) 11
set prime(5) 13

From this you should be able to see how you could use an array and substitution, via a loop, to test a number and see if it divided evenly.

A.)  Modify Assignment 6.38 to find a list of prime numbers from 1 to 100 using arrays.

B.)  Now modify the program to allow the user to enter the number of primes to find from a given starting number.

C.)  Consider multi-dimensional arrays of the form arrayName(N,N).  How many values will this array hold?

D.)  How many values for an array of the form arrayName(N,N,N)?

E.)  Use a multi-dimensional array,  entry widgets and labels to create a tic-tac-toe game.
 

Appendix 23
Write a program that will shade the area under the curve of f(x)=x*x.

Appendix 24

Write a program that will use a file to keep a list of random numbers.

Appendix 25
Write a program to test a string that the user inputs to see if the string is a palindrome.

Appendix 26
Write a program to encrypt a message then be able to decrypt the message.

Appendix T1
How many places on the earth can a Golden Bear travel, 1 mile north then 1 mile east then 1 mile south and return to the exact point from which he started?
(All positions are based on directions from the bears initials starting point!)

Appendix T2
Why is a manhole cover round?

Appendix T3
What is the exact center of the earth in real time?

Appendix T4
Assuming that a turtle runs a mile in 1 hour and a rabbit runs a mile in exactly 1 minute, if the turtle gets a 3 foot head start over the
rabbit, who would win a 1/2 mile race?  Be specific, and prepared to show (in detail) what happens when the rabbit passes the turtle, should the rabbit win.

Appendix T5
Assume that there is a bridge that is going to be destroyed in 15 minutes.  Four people are wanting to cross the bridge.  When people cross the bridge they must carry a flashlight.  Only two can cross at a time with the flashlight.  There is only one flashlight.  It takes the first person 10 minutes to cross the bridge.  It takes the second person 5 minutes to cross the bridge.  It takes the third person 2 minutes to cross the bridge.  It takes the fourth person 1 minute to cross the bridge.  Can they cross the bridge before it is destroyed?  Please explain your answer.


Table of Contents