Guest User

Untitled

a guest
Apr 27th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.22 KB | None | 0 0
  1. Imports System.Text.RegularExpressions
  2.  
  3. Module Module1
  4.  
  5.     Sub Main()
  6.         Console.WriteLine("Rectangular single-room carpeting jobs price quote")
  7.         Dim input As String
  8.         Dim roomLength As Integer = findRoomLength()
  9.         Dim roomWidth As Integer = findRoomWidth()
  10.         Dim price As Integer = findPricePerYard()
  11.         Dim squareYardage As Double = findSquareYardage(roomLength, roomWidth)
  12.         Dim materialcost As Double = findMaterialCost(squareYardage, price)
  13.         Dim totalcost As Double
  14.         Do
  15.             Console.WriteLine("Room Length = " & roomLength)
  16.             Console.WriteLine("Room Width = " & roomWidth)
  17.             Console.WriteLine("Price per square yard = $" & price)
  18.             Console.WriteLine("Square Yardage of room = " & squareYardage)
  19.             Console.WriteLine("Material cost = $" & materialcost)
  20.             If ((materialcost) < 800) Then
  21.                 Console.WriteLine("Installation cost = $200")
  22.                 totalcost = 200 + materialcost
  23.             Else
  24.                 Console.WriteLine("Installation cost is free because material cost exceeded $800")
  25.                 totalcost = materialcost
  26.             End If
  27.             Console.WriteLine("Total cost = $" & totalcost)
  28.             input = Console.ReadLine()
  29.         Loop
  30.         Console.WriteLine("Quitting now.")
  31.     End Sub
  32.     Private Function findRoomLength() As Integer
  33.         Dim input As String
  34.         Do
  35.             Console.WriteLine("Please enter room length in ft")
  36.             input = Console.ReadLine()
  37.             If (onlyNumbers(input) = False) Then
  38.                 Console.WriteLine("Input only numbers")
  39.  
  40.             End If
  41.         Loop While (onlyNumbers(input) = False And input.Length > 0)
  42.         Return input
  43.     End Function
  44.     Private Function findRoomWidth() As Integer
  45.         Dim input As String
  46.         Do
  47.             Console.WriteLine("Please enter room width in ft")
  48.             input = Console.ReadLine()
  49.             If (onlyNumbers(input) = False) Then
  50.                 Console.WriteLine("Input only numbers")
  51.  
  52.             End If
  53.         Loop While (onlyNumbers(input) = False And input.Length > 0)
  54.         Return input
  55.     End Function
  56.     Private Function findPricePerYard() As Integer
  57.         Dim input As String
  58.         Do
  59.             Console.WriteLine("Please enter the price of the carpeting material on a per-square-yard basis")
  60.             input = Console.ReadLine()
  61.             If (onlyNumbers(input) = False) Then
  62.                 Console.WriteLine("Input only numbers")
  63.  
  64.             End If
  65.         Loop While (onlyNumbers(input) = False And input.Length > 0)
  66.         Return input
  67.     End Function
  68.     Private Function onlyNumbers(ByVal str As String) As Boolean
  69.         Return str.All(AddressOf Char.IsNumber)
  70.     End Function
  71.     Private Function findSquareYardage(ByVal length As Integer, ByVal width As Integer) As Double
  72.         Dim yardLength As Double = length / 3
  73.         Dim yardWidth As Double = width / 3
  74.         Return yardLength * yardWidth
  75.     End Function
  76.     Private Function findMaterialCost(ByVal squareyards As Double, ByVal pricePerYard As Integer) As Double
  77.         Return pricePerYard * squareyards
  78.     End Function
  79. End Module
Advertisement
Add Comment
Please, Sign In to add comment