Public Class Conditionals Private Sub Conditionals_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '1) 'Mr. Spacely has been rethinking the company's shipping schemes. As an employee for Spacely's 'Sprockets, Spacely has asked you to write a quick program that will be used to determine shipping 'costs. 'A total purchase of items totaling under $50, we charge $5 shipping. 'A total purchase of items totaling $50 and over, there is no shipping charge. Dim TotalCost, Cost, Shipping As Decimal Cost = 49 If Cost < 50 Then Shipping = 5.0 ElseIf Cost >= 50 Then Shipping = 0.0 End If TotalCost = Cost + Shipping MessageBox.Show(TotalCost) '2) 'You are looking for something to control your heat in your apartment and you discover there is 'NOT an app for that. It's about time that someone created one. You decide that you are the one 'to do it. Here's what you want to do. '- You want to turn the heat on when the temp has dropped below 72 '- You also want to turn the AC on when the temp gets above 76 'Your app should display in a message box if the heat is on, the AC is on, or if the system is idle. 'Plug in different temps for the room in a variable to see what the thermostat will do with it. Dim Temp As Integer Temp = 76 If Temp < 72 Then MessageBox.Show("The Heat Is On") ElseIf Temp > 76 Then MessageBox.Show("The AC Is On") Else MessageBox.Show("The System Is Idle") End If '3) 'a. 0-2 yrs - XS 'b. 3-4 yrs - S 'c. 5-8 yrs - M 'd. 9-12 yrs - L 'e. 13+ yrs - XL 'You are working on a clothing website where people can buy kids socks. It's really hard for the 'customers to know what size they should buy for what age. It would be a good idea for the 'customer to have a tool to input their child's age and have the website suggest a size for them. 'Write a tool where you can set the age as a variable and have it suggest on of the sizes below: Dim Shirts As Integer Select Case Shirts Case 0 - 2 MessageBox.Show("XS") Case 3 - 4 MessageBox.Show("S") Case 5 - 8 MessageBox.Show("M") Case 9 - 12 MessageBox.Show("L") Case Is >= 13 MessageBox.Show("XL") End Select
Thursday, February 3, 2011
Programming 2 /* Conditionals */
Subscribe to:
Post Comments (Atom)
Classes
Programming II
Advanced Relational Database
No comments:
Post a Comment