Chapter four selected exercises with solutions. 4.2.
-
Upload
doreen-kelley -
Category
Documents
-
view
225 -
download
0
Transcript of Chapter four selected exercises with solutions. 4.2.
![Page 1: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/1.jpg)
Chapter four selected exercises with solutions
![Page 2: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/2.jpg)
4.2
![Page 3: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/3.jpg)
4. 1 3
2 5
2 3
1 4
2 3
![Page 4: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/4.jpg)
![Page 5: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/5.jpg)
6. NE
![Page 6: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/6.jpg)
![Page 7: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/7.jpg)
8. Approximate Annual Wage: $20,000.00
![Page 8: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/8.jpg)
![Page 9: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/9.jpg)
10. If you fail to plan then you plan to fail
![Page 10: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/10.jpg)
![Page 11: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/11.jpg)
14. Hello Ray and Bob
and Bob
![Page 12: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/12.jpg)
![Page 13: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/13.jpg)
![Page 14: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/14.jpg)
Private Sub cmdDisplay_Click() Dim first As String, last As String, fInit As String, lInit As
String 'Display initials picOutput.Cls Call InputNames(first, last) Call ExtractInitials(first, last, fInit, lInit) Call DisplayInitials(fInit, lInit)End Sub
Private Sub InputNames(first As String, last As String) 'Get the persons first and last name first = InputBox("Enter your first name:") last = InputBox("Enter your last name:")End Sub
![Page 15: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/15.jpg)
Private Sub ExtractInitials(first As String, last As String, fInit As String, lInit As String)
'Determine the initials of the first and last names fInit = Left(first, 1) lInit = Left(last, 1)End Sub
Private Sub DisplayInitials(fInit As String, lInit As String) 'Display the initials picOutput.Print "Your initials are "; fInit; "."; lInit; "."End Sub
![Page 16: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/16.jpg)
Or without calls to sub procedures
Private Sub cmdDisplay_Click() Dim first As String, last As String, fInit As String, lInit As String 'Display initials picOutput.Cls
first = InputBox("Enter your first name:") last = InputBox("Enter your last name:")
fInit = Left(first, 1) lInit = Left(last, 1)
picOutput.Print "Your initials are "; fInit; "."; lInit; "."End Sub
![Page 17: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/17.jpg)
![Page 18: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/18.jpg)
![Page 19: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/19.jpg)
Dim total As Single 'In (Declarations) section of (General)
Private Sub cmdProcessItem_Click() Dim item As String, price As Single 'Process item; display part of sales receipt Call InputData(item, price) total = total + price Call ShowData(item, price) txtItem.Text = "" txtPrice.Text = "" txtItem.SetFocusEnd Sub
![Page 20: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/20.jpg)
Private Sub InputData(item As String, price As Single)
'Input item name and price item = txtItem.Text price = Val(txtPrice.Text)End Sub
Private Sub ShowData(strItem As String, numItem As Single)
'Display data on specified line picReceipt.Print strItem; Tab(15);
FormatNumber(numItem)End Sub
![Page 21: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/21.jpg)
Private Sub cmdDisplay_Click()
Dim tax As Single
'Display sum, tax, and total
tax = total * 0.05
tax = Round(tax, 2)
picReceipt.Print Tab(15); "-------"
Call ShowData("Sum", total)
Call ShowData("Tax", tax)
Call ShowData("Total", total + tax)
End Sub
![Page 22: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/22.jpg)
4.3
![Page 23: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/23.jpg)
4. 400
![Page 24: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/24.jpg)
![Page 25: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/25.jpg)
6. The day is Wed
![Page 26: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/26.jpg)
![Page 27: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/27.jpg)
8. 15 5
![Page 28: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/28.jpg)
![Page 29: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/29.jpg)
![Page 30: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/30.jpg)
Private Sub cmdCalcIdealAge_Click() Dim manAge As Integer 'Calculate ideal age for wife, according to Plato picIdealAge.Cls Call InputManAge(manAge) Call ShowWifeAge(manAge)End Sub
Private Sub InputManAge(manAge As Integer) manAge = Val(InputBox("Enter your age: "))End Sub
Private Sub ShowWifeAge(manAge As Integer) picIdealAge.Print "The ideal age of your wife is";
Int(manAge / 2 + 7)End Sub
![Page 31: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/31.jpg)
![Page 32: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/32.jpg)
![Page 33: Chapter four selected exercises with solutions. 4.2.](https://reader035.fdocuments.us/reader035/viewer/2022062301/56649ea05503460f94ba2690/html5/thumbnails/33.jpg)
Private Sub cmdCalculate_Click() picResult.Cls picResult.Print "Your BMI is"; BMI(Val(txtWeight),
Val(txtHeight))End Sub
Private Function BMI(w As Single, h As Single) As Single 'Calculute body mass index BMI = Round(703 * w / h ^ 2)End Function