Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Text.RegularExpressions
- Module Module1
- Sub Main()
- Console.WriteLine("Rectangular single-room carpeting jobs price quote")
- Dim input As String
- Dim roomLength As Integer = findRoomLength()
- Dim roomWidth As Integer = findRoomWidth()
- Dim price As Integer = findPricePerYard()
- Dim squareYardage As Double = findSquareYardage(roomLength, roomWidth)
- Dim materialcost As Double = findMaterialCost(squareYardage, price)
- Dim totalcost As Double
- Do
- Console.WriteLine("Room Length = " & roomLength)
- Console.WriteLine("Room Width = " & roomWidth)
- Console.WriteLine("Price per square yard = $" & price)
- Console.WriteLine("Square Yardage of room = " & squareYardage)
- Console.WriteLine("Material cost = $" & materialcost)
- If ((materialcost) < 800) Then
- Console.WriteLine("Installation cost = $200")
- totalcost = 200 + materialcost
- Else
- Console.WriteLine("Installation cost is free because material cost exceeded $800")
- totalcost = materialcost
- End If
- Console.WriteLine("Total cost = $" & totalcost)
- input = Console.ReadLine()
- Loop
- Console.WriteLine("Quitting now.")
- End Sub
- Private Function findRoomLength() As Integer
- Dim input As String
- Do
- Console.WriteLine("Please enter room length in ft")
- input = Console.ReadLine()
- If (onlyNumbers(input) = False) Then
- Console.WriteLine("Input only numbers")
- End If
- Loop While (onlyNumbers(input) = False And input.Length > 0)
- Return input
- End Function
- Private Function findRoomWidth() As Integer
- Dim input As String
- Do
- Console.WriteLine("Please enter room width in ft")
- input = Console.ReadLine()
- If (onlyNumbers(input) = False) Then
- Console.WriteLine("Input only numbers")
- End If
- Loop While (onlyNumbers(input) = False And input.Length > 0)
- Return input
- End Function
- Private Function findPricePerYard() As Integer
- Dim input As String
- Do
- Console.WriteLine("Please enter the price of the carpeting material on a per-square-yard basis")
- input = Console.ReadLine()
- If (onlyNumbers(input) = False) Then
- Console.WriteLine("Input only numbers")
- End If
- Loop While (onlyNumbers(input) = False And input.Length > 0)
- Return input
- End Function
- Private Function onlyNumbers(ByVal str As String) As Boolean
- Return str.All(AddressOf Char.IsNumber)
- End Function
- Private Function findSquareYardage(ByVal length As Integer, ByVal width As Integer) As Double
- Dim yardLength As Double = length / 3
- Dim yardWidth As Double = width / 3
- Return yardLength * yardWidth
- End Function
- Private Function findMaterialCost(ByVal squareyards As Double, ByVal pricePerYard As Integer) As Double
- Return pricePerYard * squareyards
- End Function
- End Module
Advertisement
Add Comment
Please, Sign In to add comment