Chapter 3 Exercises **PUT ALL OF THE FOLLOWING EXERCISES IN ONE PROJECT WITH AN INTRO FORM TO ACCESS EACH EXERCISE **SAVE PROJECT AS: Chapter 3 Exercises 1) IF or Case - Tall or Short Program a) When asked most older people can easily state their height in terms of inches or feet and inches (imperial system). Now the standard is to use the metric system. On our drivers license our height is stated in centimeters. Note that 1 inch = 2.54 centimeters. You have been asked to prepare the pseudo-code and then write the "interactive" program which requests a person's name and their height in inches. The program would then print their height in centimeters along with the person's name and other identifying information. Program Specifications: For example: Please enter your name. Hi Marie! What is your height in inches? 70 Marie, your height is 177.8 centimeters. b) To provide more flexibility, you are asked to modify your pseudo-code and program for the above problem to allow a person to enter their height in feet and inches. Also, you are asked to identify anyone with a height greater than 180 centimeters by a message "You are above the average in height" as an output. You can also include messages for shorter people. Remember to include prompts for requesting the height in both feet and inches. How many inches in a foot??? Save as: Height 2) Order a Sundae! With or Without Nuts? Most of us enjoy a sundae of some sort. Some of us prefer to have a chocolate sundae with nuts and some of us enjoy a strawberry sundae with no nuts. You are asked to write a program that asked the user what type of sundae they would like. The flavours being chocolate fudge, caramel, butterscotch and strawberry. You must also include the choice of nuts or no nuts. You will need Program Specifications: a.) Use three nested if's on and If...ElseIf...ElseIf..Else...Then clause because you have four types of sundaes and you need to ask if nuts should be added or not each time. b.) Use option boxes for the sundaes and check boxes for the nuts or no nuts. c) Have the program confirm the order with a Message box (ie: You have ordered a chocolate sundae with nuts) File Name: Sundae Enhancements: Include the cost of the sundae, extra toppings and peanut cost. 3) The Batting Average Program Summers seem to pass us by so quickly. But the memories of baseball will always remain as well as how much do baseball players really make. Write a program that calculates how much a baseball player would be paid depending on their type of bat and batting average. Each play earns a base salary of $20,000 per year. Batters can also earn bonuses on their performance. Bat/Hit Type Bonus (Dollar Value) Single $1,000.00 Double $2,000.00 Triple $3,000.00 Home Run $4,000.00 Grand Slam - bases loaded $5,000.00 The players can also earn bonuses if their batting averages are within certain ranges. Average Bonus Dollar Value 0-.200 $10,000.00 .201-.400 $20,000.00 .401 - .600 $30,000.00 .601 - .800 $40,000.00 .801 and over $50,000.00 Note: you could make your own average ranges. Program Specifications: a.) Any selection statements that are suitable to the program. b.) Declare variables necessary, use the formats of Val and Currency were needed. Save As: Baseball 4) Golfing - Case Create the following interface. The game of golf has many rules and regulations as well as etiquette. The main focus of golf is the final score that was shot during the day. For example a golfer will say "I shot a 70" at "Lionhead". Assuming that the player has played 18 holes. The score of a golf game is based on the number of strokes at each hole it has taken a golfer to put the golf ball in the hole. The purpose of this program is to determine: The number of strokes under or over the player has shot. Each hole has a certain par. No holes even exceed a par 5. For example the first hole, is a par 4. The player, to get a good score, must try to use 4 or less strokes to get the golf ball into the hole. The player has shot a 3. So the Difference from par is -1. This is calculated by Score - Par, 3-4= -1. The player is 1 under par. This is termed a birdie. An eagle is two under par. If the player took 5 shots to get the golf ball into the hole. The player is 1 over. Again Score - Par, 5 -4 =1. This is termed a boggie. Two over is termed a double boggie. Program Specifications: I. Create a program which calculates the difference from par. you will assume the golfer is playing 18 holes. The following holes have the following par values: Hole Number Par Value 1,2,8,13,15,18 3 4,5,7,9,10,12,16 4 3,6,11,14,17 5 ii. Make sure you use variables for score, hole, par and difference. File Name: Golf 5) Sam the CD Man Create the following interface: Sam the CD Man has opened up a new store in the mall nearest you. The price for all CD's is $11.99. There is a special offer valid any time. The offer is that if you purchased 5 or more CD's you get a 15% discount. If you purchase 10 CD you get a 20% discount. The store manager which is you the programmer has devised a program to calculate the price. Program Specifications: 1. Using your knowledge in if statements create a program to calculate the price of the CD or CD's purchased. Make sure that a discount is offered based on the number of CD's purchased. 2. Write the program so that the input (number of CD's), processing (calculation of price) and output (final price) is attached to the speaker button. Use Val and Currency where appropriate Enhancements: Modify the program to include 8% PST and 7% GST. Modify the program so that the price of the CD can be altered on the screen. CD's can range from $6.99 and above. File Name: CD 6) Famous Programmers Theater - The Movie Program A new movie theater titled the "Famous Programmers Theater" has opened it's doors to the public. You have been hired as the programmer for the theater. The program that the company requires is the automatic movie ticket machine. Patrons can visit an automatic teller machine and buy tickets. The user should be able to click on the movie of the week that they wish to see, the number of tickets, the time of day the movie is showing, the day of the week and their age. Program Specifications: Create an interface that incorporates the following: 1. Option boxes for the number of tickets to be purchased. 2. A check box for matinee discounts. 3. Option boxes for the age ranges (Child, Adult and Senior). 4. Option boxes for the day of the week the movie is for (Monday to Sunday). 5. An area to display the price. 6. A command box to process the price. 7. Option boxes for a list of 10 movies that the user can choose from. 8. Don't forget the clear and exit command buttons. 9. Declare any variables and assign them to the appropriate objects. 10. Include another form to order extras (popcorn, drinks, candy) and add to total Create an objects table using the format below. Object Name Property Text Property Caption Property Variable Name Processing the price: You will need to create a multiple if statement to incorporate the age factor, time of day or matinee discount, day of the week (Tuesday is half price.) For example: If it is Tuesday and a matinee show for an adult the price is $4.50. If it is Monday and the movie is at 7:10 pm for an adult the ticket price is $8.00. File Name: Movie 7) The Learning Tower of Pizza The program titled "The Learning Tower of Pizza" will provide you with a firm ground of the if..then..else statement, check boxes, option boxes, frames, logical and relational operators. Create the form located on below. Program Specifications: 1. Use at least two forms. One form for the main order and one form for the extras and beverages. 2. Declare all variables, use val and currency where appropriate. 3. Use nested selection or case where appropriate. 4. All calculations must be included in the appropriate command buttons. Save As: Pizza 8) Magazine Subscription Browsing through a magazine before purchasing it is a common practice for most of us. It never fails that a small piece of paper falls out of the magazine and floats down to your feet. The small paper is for a magazine subscription. The subscription states FREE for the first month or SPECIAL DISCOUNT off the shelf price. Create a program that allows a user to order a magazine of your choice off a computer. Program Specifications: 1. Create the subscription the similar to your paper version. 2. Have an area for the user to enter in their first and last names and their full address. 3. Option boxes for 1 or two year subscription. 4. Option boxes for method of payment (eg. bill me later, cheque, visa number). 5. Display the cost of the magazine including tax. 6. Display any discounts for ordering for two years 7. Include colour and a graphic. File Name: Magazine