Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Total Marks: 35 (Labs grading category) CS30S / Kozub / March 2016 Lab 3: If Statements Instructions: Follow all proper programming and form design practices. This includes naming conventions, correct variable use, access keys, documentation, etc. Complete each question in a separate VB project. When you’re done, copy all projects to one folder, put your name in it, and zip the file. Upload it to the DropBox for submission. New topics covered: if statements, logical operators, random, form-level variables Question 1: Express Café (7 marks: 2 form design, 1 comments, 4 code) Create an Express Café Payroll application that calculates gross weekly wages given the hours worked and the hourly rate. The program also allows the user to select, using radio buttons, whether taxes should be included in the final calculation or not. If taxes are included, add in a 13% tax to the total calculation and print out a message saying “with tax”. If the user is exempt from taxes, do not add in any tax, and print out a message saying “without taxes”. Round the answer. Also, make sure to check for invalid input and re-prompt the user as necessary. See the form below: Question 2: Grade Tracker (7 marks: 2 form design, 1 comments, 4 code) Create a Grade Tracker application that reads in percent grades and continuously displays the number of students who passed (e.g. 50 or higher) and the number who failed. Hint: use form-level variables to track the number of students who pass and fail and increment them depending on the input. Each time a grade is entered, the textbox should be cleared to allow for new numbers to be inputted. Also, check for invalid data (e.g. grades below 0 and greater than 100) and re-prompt the user as necessary. Question 3: Rock, Paper, Scissors (12 marks: 3 form design, 1 comments, 8 code) Create a basic rock, paper scissors game in which a player will play against a computer. You’ll need three buttons: one each for rock, paper and scissors. When the user presses the appropriate button, have the computer randomly choose rock, paper or scissors for itself. You can do this by assigning each of RPS to the numbers 1, 2 and 3, and then checking who wins with an if statement. For instance, suppose this chart indicates the number assigned to each of RPS: Rock Paper Scissors 1 2 3 Have a variable each for the computer’s choice (randomly generated) and the player’s choice. Then, check who wins. For example, if the computer has rock (1) and the user has paper (2), the user wins because paper covers rock. For each of the buttons, include a picture of the corresponding choice (e.g. rock, paper or scissors). A message will have to indicate the result of the game. Finally, use form-level variables to keep track of the number of wins for each player, ties, and total games played. When the user wins, add 1 to his/her total win count; do the same for the computer. Also include a Reset button to allow the player to start over from scratch. See the demo program (online) for inspiration. Your program doesn’t need to look exactly like this (believe it or not, this is a program I made when I was in high school). Don’t worry about the dialogue box that asks for the user’s name. Question 4: Leap Year (9 marks: 2 form design, 1 comments, 6 code) Complete the Leap Year program below. The user is asked for a date in number form. To determine if a year is a leap year, use the following steps: 1. A year is a leap year if it is divisible by 400 (e.g. 2000 was a leap year) 2. A year is not a leap year if it is divisible by 100 (e.g. 1900 was not a leap year) 3. A year is a leap year if it is divisible by 4 (e.g. 2004 is a leap year) (Hint: use these steps as the first three conditions for an If / ElseIf structure). Also complete the button Days in Month which calculates the number of days in the given month. Use the internet if you don’t know how many days are in each month. Remember, if it is a leap year, February has 29 days. Make sure to check for invalid data and display a corresponding error message. Student: ______________________ CS30S / Kozub Lab 3 Marking Sheet 1: Express Café Form design 2: Grade Tracker Form design /2 Comments 3: Rock, Paper, Scissors Form design /2 Comments 4: Leap Year Form design /3 Comments /2 Comments /1 /1 /1 /1 Code use of if statements variables calculations input/output rounding misc Code use of if statements variables (form level) input/output valid data misc Code use of if statements variables (form level and local) use of Rnd() correctly determines winner track scores picures misc Code use of if statements variables (form level) input/output valid data works correctly determines days in month misc /4 /4 /8 /6 Teacher Feedback Teacher Feedback Teacher Feedback Teacher Feedback Total: Total: Total: Total: /7 /7 / 12 /9 Total Lab Mark: / 35