You have been asked to write a program for a plumbing supply warehouse. The have several types of tubing that then sell for different prices. The following is the price list based upon a linear foot of tubing: Plastic = .30; PVC = .60; aluminum = .75; copper = 1.00; Stainless Steel = 1.25; bronze = 1.35; gold = 5.50. They want to see at the end of the program what type pipe was ordered, how many feet were ordered (only whole feet will be input) and the total amount of the order.
Problem Statement:
Assumptions:
Only Plastic, PVC, Stainless Steel, bronze, and gold tubing
available
Only one order at a time
only feet not inches are evaluated
Plastic = .30
PVC = .60
aluminum = .75
copper = 1.00
Steel = 1.25
bronze = 1.35
gold = 5.50
Given:
Type of tubing: Plastic, PVC, Stainless Steel, bronze, and
gold
Number of feet of tubing
Calculations:
If Plastic Length * plastic
ElseIF PVC Length * PVC
ElseIF aluminum Length * aluminum
ElseIF copper Length * copper
ElseIF Stainless Steel Length * steel
ElseIF bronze Length *bronze
ElseIF gold Length * gold
Output
type pipe
how many feet
total amount of the order.
Human Algorithm:
1. Plastic = .30
2. PVC = .60
3. aluminum = .75
4. copper = 1.00
5. Steel = 1.25
6. bronze = 1.35
7. gold = 5.50
8. Input the type of tubing
9. Input the number of feet of tubing
10.
If Plastic then totalcost = Length * .30
11. ElseIF PVC then totalcost = Length * .60
12. ElseIF aluminum then totalcost = Length * .75
13. ElseIF copper then totalcost = Length * 1.00
14. ElseIF Stainless Steel then totalcost = Length * 1.25
15. ElseIF bronze then totalcost = Length *1.35
16. ElseIF gold then totalcost = Length * 5.50
17 Output Type of Pipe
18. Output number of feet
19. Output total cost
Flowchart : Visual Logic does not display Select Case. You must use If...elseif..else logic then code it using select case
If we were to flow chart this as IF...ElseIf...Else this is how it would flow:

Now Code it using html kit
This is the code if you did the nested If...ElseIf....Else structure:
<Script language = "VBScript">
Dim tubetype, NumOfFeet, totalorder
'assignments
Plastic = .30
PVC = .60
aluminum = .75
copper = 1.00
Steel = 1.25
bronze = 1.35
gold = 5.50
'input
tubetype = InputBox("What type do you want to order Plastic, PVC, aluminum,
copper, Stainless Steel, bronze, or gold")
NumOfFeet = InputBox("How many feet do you want")
'calculations
If tubetype = "Plastic" then
totalorder = NumOfFeet * plastic
ElseIf tubetype = "PVC" then
totalOrder = NumOfFeet * PVC
ElseIf tubetype = "Aluminum" then
totalOrder = NumOfFeet * aluminum
ElseIf tubetype = "Copper" then
totalOrder = NumOfFeet * copper
ElseIf tubetype = "Bronze" then
totalOrder = NumOfFeet * steel
ElseIf tubetype = "Gold" then
totalOrder = NumOfFeet * 5.50
Else
Msgbox("You need to type Plastic, PVC, Aluminum, Copper, Bronze, or
Gold")
End If
' output
document.write "You ordered " & NumOfFeet & " feet of " & tubetype & "for a
total amount of $" & totalorder
</script>
The following is the same program written using the Select Case Structure:
<Script language = "vbscript">
Dim tubetype, NumFeet, TotalOrder
tubetype = inputbox("What type of tube? plastic, PVC, aluminum, bronze,
Stainless Steel, copper, gold")
NumFeet = inputbox("How many feet do you want?")
Select Case tubetype '<-- we are comparing
what is in the place in memory called "tubetype"
Case "plastic"
'<-- we are matching "plastic" with what is in the memory location called "tubetype"
TotalOrder = NumFeet * .30
Case "PVC"
'<--If "plastic" wasn't in tubetype then we compare "PVC" to what's in tubetype
TotalOrder = NumFeet * .60
Case "aluminum"
TotalOrder = NumFeet * .75
Case "bronze"
TotalOrder = NumFeet * 1.00
Case "Stainless Steel"
TotalOrder = NumFeet * 1.25
Case "copper"
TotalOrder = NumFeet * 1.50
Case "gold"
Totalorder = NumFeet * 5.50
Case Else
MsgBox(" Type does not Match")
End Select
Document.write "Total order is $" & TotalOrder
Document.write "<p>Total number of feet is " & Numfeet
Document.write "<p>Type of pipe " & tubetype
</Script>