Visual Basic Programming and Interface
The Interface of Average Score Solution
Code
Public Class Form
Private Sub-Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' calcualtes and displays the average solution ' declare variables
Dim intAllen As Integer
Dim intPeter As Integer
Dim intSmith As Integer
Dim intJohn As Integer
Dim intAverage As Integer
'assign input to variables
Integer.TryParse (txtAllen.Text, intAllen)
Integer.TryParse (txtPeter.Text, intPeter)
Integer.TryParse (txtSmith.Text, intSmith)
Integer.TryParse (txtJohn.Text, intJohn)
' caculate average intAverage = (intAllen + intPeter + intSmith + intJohn) / 4
' display average lblAverage.Text = intAverage.ToString ("CO")
End Sub
End Class
Chapter 7: Question 8.
Code
Public Class Form1
Private Sub-Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' calcualtes and displays the total sales ' declare variables
Dim intPeter As Integer
Dim intAllen As Integer
Dim intSmith As Integer
Dim intHelen As Integer
Dim intTotal As Integer
'assign input to variables
Integer.TryParse (txtPeter.Text, intPeter)
Integer.TryParse (txtAllen.Text, intAllen)
Integer.TryParse (txtSmith.Text, intSmith)
Integer.TryParse (txtHelen.Text, intHelen)
' caculate total sales intTotal = (intPeter + intAllen + intSmith + intHelen)
' display total sales lblTotal.Text = intTotal.ToString ("CO")
End Sub
End Class
Chapter 8: Exercises 10
Output: Calculate the food's fat calories and its fat percentage
Processing: Calories
Input: Food's fat grams
Number of calories
Each gram of fat contains 9 calories
Algorithms
1.enter the number of grams of fat and calories contained with a specific food.
2 calculate the fat calories "by multiplying the food's fat grams by 9" (Zak, 2014 p 183).
3. "calculate the fat percentage by dividing the food's fat calories by its total calories and then multiplying the result by 100" (Zak, 2014 p 183).
4. if fat percentage display with the zero decimal places
End if
5. display the fat calories
Display the fat percentages
Code
Public Class Form1
Private Sub-Form1_Load (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' calculates the food fat calories and its fat percentage
Const gram As = 9
Dim intCalories As Integer
Dim decpercentage As Decimal
' assign gram, calories and price to variables
Integer.TryParse (txtGram.Text, intGram)
Integer.TryParse (txtFat.Text, intFat)
Integer.TryParse (txtCalories.Text, intCalories)
Decimal.TryParse (txtPercentage.Text, decpercentage)
' calculate fat percentage the food's fat calories / total calories * 100
intCalories = intGram * 9
intPercentange = intCalories / intCalories x 100
' display fat percentage ' display calories
End Sub
End Class
Chapter 8: Exercises 13
Output: employee net pay
Input: hours worked rate of pay
Algorithm:
1.enter hourly worked per week
2 enter rate of pay
3. employees are not allowed to work more than 40 hours a week
5. calculate gross pay
6. calculate FWT (federal withholding tax), which is 20% of gross pay
7. calculate FICA (Social Security & Medical Tax), which is 8% of gross pay
8.calculate state income tax, which is 2% of gross pay
9. calculate an net pay= gross pay - ( FWT +FICA +state income tax)
Interface of Net Pay Project
Code
Public Class Form1
You’re 80% through this paper. Sign up to read the full paper.
Sign Up Now — Instant Access Already a member? Log inAlways verify citation format against your institution’s current style guide requirements.