Showing posts with label word problem. Show all posts
Showing posts with label word problem. Show all posts

Wednesday, February 2, 2011

Word Problems 2 Spacely's Sprockets, Heat problem, Socks

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.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim purchase, shipping, total As Double
purchase = CDbl(txtpurchase.text)
shipping = 5
'Calculate total
If purchase >= 50 Then
total = FormatCurrency(purchase)
ElseIf purchase < 50 Then
total = purchase + shipping
End If
'Display total
MessageBox.Show("Your total is: " & FormatCurrency(total), "Please Pay")
End Sub
End Class


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.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim temp As Double
temp = CDbl(txtpurchase.Text)
'Calculate total
If temp <= 72 Then
MessageBox.Show("The heat is on.", "Heat")
ElseIf temp > 72 And temp < 76 Then
MessageBox.Show("The system is idle", "Idle System")
ElseIf temp >= 76 Then
MessageBox.Show("The A/C is on.", "A/C")
End If
End Sub
End Class


3.) 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:
a.0-2 yrs -XS
b.3-4 yrs -S
c.5-8 yrs -M
d.9-12 yrs -L
e.13+ yrs -XL

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim age As Double
age = CDbl(txtpurchase.Text)
'Calculate total
If age <= 2 Then
MessageBox.Show("Your child's size is XS.", "XS")
ElseIf age >= 3 And age <= 4 Then
MessageBox.Show("Your child's size is Small", "Small")
ElseIf age >= 5 And age <= 8 Then
MessageBox.Show("Your child's size is Medium", "Medium")
ElseIf age >= 9 And age <= 12 Then
MessageBox.Show("Your child's size is Large", "Large")
ElseIf age >= 13 Then
MessageBox.Show("Your child's size is X-Large.", "X-Large")
End If
End Sub
End Class

Monday, January 31, 2011

Word Problem 6 - Quiz scores

a.) Given the table of quiz marks out of 25 in each subject calculate How many marks did Brian totally obtain in Mathematics and Science?
Write a program in Visual Basic to calculate the marks Brian obtained in Mathematics and Science.

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim M, S, marks As Integer
'Set values
M = 7 'Marks in Mathmetics
S = 22 'Marks in Science
marks = M + S
'Display results
MessageBox.Show("Brian has " & marks & " marks in Mathematics and Science.")
End Sub
End Class


b.) How many more marks does Andrew need for a perfect score in Mathematics?

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim M, S, marks As Integer
'Set values
M = 18 'Brian's actual marks
S = 25 'total possible
marks = S - M
'Display results
MessageBox.Show("Brian needs " & marks & " marks for a perfect score in Mathematics.")
End Sub
End Class


c.) What is Andrew's percentage for all of the quizzes together?

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim M, S, En, G As Integer
Dim marks As Decimal
'Set values
M = 18 'marks in Mathematics
S = 7 'marks in Science
En = 12 'marks in English
G = 15 'marks in Geography
marks = (S + M + En + G) / 100
'Display results
MessageBox.Show("Brian has " & FormatPercent(marks) & " marks for all the quizzes together.")
End Sub
End Class

Word Problem 5 - Inglebert's Apples and Oranges with variable

Inglebert has 15 apples and 3 times as many oranges. How may pieces of fruit does she have?
Create a program in Visual Basic to calculate the number of pieces of fruit that Inglebert has. Enter the initial value for apples in a text box.

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim A, O, pieces As Integer
'Set values
A = txtInitial.Text
O = A * 3
pieces = A + O
'Display results
MessageBox.Show("Inglebert has " & pieces & " pieces of fruit.")
End Sub
End Class

Word Problem 5 - Inglebert's Apples and Oranges

Inglebert has 15 apples and 3 times as many oranges. How many pieces of fruit does she have?
Create a program in Visual Basic to calculate the number of pieces of fruit Inglebert has with the given numbers.

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
'Declare variables
Dim A, O, pieces As Integer
'Set values
A = 15
O = A * 3
pieces = A + O
'Display results
MessageBox.Show("Inglebert has " & pieces & " pieces of fruit.")
End Sub
End Class

Word Problem 4 - Horses in the field part 2

There are 33 horses in a field. 15 horses go into the barn. Then 7 of them come back out. How many horses are standing in the field?
Write a program in Visual Basic to find out how many horses are standing in the field.
Gather the initial value in a text box.

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  

'Declare variables
Dim I, O, B, horses As Integer
'Set values
O = 15
I = txtInitial.Text
B = 7
horses = I - O + B
'Display results
MessageBox.Show("There are " & horses & " horses in the field.")
End Sub
End Class

Word Problem 4 - Horses in the field

There are 33 horses in a field. 15 horses go into the barn. Then 7 of them come back out. How many horses are standing in the field?
Write a program in Visual Basic to find out how many horses are standing in the field.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim I, O, B, horses As Integer
'Set values
O = 33
I = 15
B = 7
horses = O - I + B
'Display results
MessageBox.Show("There are " & horses & " horses in the field.")
End Sub
End Class

Friday, January 28, 2011

Word Problem 3 - Apples and Oranges

Ole has 15 apples and 12 oranges. How many pieces of fruit does he have?

Write a program in Visual Basic to display the number of pieces of fruit Ole has.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim A, O, fruit As Integer
'Set values
A = 15
O = 12
fruit = A + O
'Display results
MessageBox.Show("Ole has " & fruit & " pieces of fruit.")
End Sub
End Class

Word Problem 2 - Mega Burgers in Visual Basic

Diane bought 7 Mega Burgers. Each Mega Burger cost $4. How many dollars did she spend on the Mega Burgers?

Write a program to display how much the Mega Burgers cost in Visual Basic.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim MB, Cost, TotalPrice As Integer
'Set values
MB = 7
Cost = 4
TotalPrice = MB * Cost
'Display results
MessageBox.Show("The Mega Burgers cost " & FormatCurrency(TotalPrice))
End Sub
End Class

Word Problem 1 - Stuffed Animals in Visual Basic

Morgan loves collecting small stuffed animals. She has 6 cows and 7 sheep. How many animals does she have in her collection?
Write a program in Visual Basic to display the number of stuffed animals in a message box.

 Public Class Form1  
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Declare variables
Dim C, S, TA As Integer
'Set values
C = 6
S = 7
TA = C + S
'Display results
MessageBox.Show("Morgan has " & TA & " stuffed animals.")
End Sub
End Class