Lynix_

H/W 2

Nov 6th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Module Module1
  2.  
  3.     Sub Main()
  4.         'BiggestNumber()
  5.        'DriversAge()
  6.        'Currency()
  7.        'RomanNumerals()
  8.        'Buissness()
  9.        'SportsClub()
  10.        'RockPaperScissors()
  11.        'LogicGates()
  12.        AdvancedNumerals()
  13.     End Sub
  14.  
  15.     Sub BiggestNumber()
  16.         Dim Num1 As Integer
  17.         Dim num2 As Integer
  18.  
  19.         Console.WriteLine("Please input the first number")
  20.         Num1 = Console.ReadLine()
  21.         Console.WriteLine("Please input the second number")
  22.         num2 = Console.ReadLine()
  23.  
  24.         Console.WriteLine("The bigger number is: ")
  25.         If Num1 > num2 Then
  26.             Console.Write(Num1)
  27.         ElseIf Num1 < num2 Then
  28.             Console.Write(num2)
  29.         End If
  30.         Console.ReadKey()
  31.     End Sub
  32.  
  33.     Sub DriversAge()
  34.         Dim Age As Integer
  35.  
  36.         Console.WriteLine("Please input your age (years)")
  37.         Age = Console.ReadLine()
  38.         If Age >= 17 Then
  39.             Console.WriteLine("You are old enough to drive")
  40.         ElseIf Age < 17 Then
  41.             Console.WriteLine("You are not old enough to drive")
  42.         End If
  43.         Console.ReadKey()
  44.     End Sub
  45.  
  46.     Sub Currency()
  47.         Dim Input As Single
  48.         Dim Euros As Single
  49.         Dim Commision As Single
  50.         Dim Output As Single
  51.  
  52.         Console.WriteLine("Please enter the amount of Pounds you wish to convert to Euros")
  53.         Input = Console.ReadLine()
  54.         Commision = Euros / 100 * 2
  55.  
  56.         If Commision < 2 Then
  57.             Commision = 2
  58.         End If
  59.  
  60.         Euros = (Input * 1.5) - Commision
  61.         Output = Euros - Commision
  62.         Console.WriteLine("You get: " & Euros & " Euros")
  63.         Console.ReadKey()
  64.  
  65.     End Sub
  66.  
  67.     Sub RomanNumerals()
  68.         Dim UserInput As Integer
  69.         Dim Numeral As String = "I"
  70.  
  71.         Console.WriteLine("Please input a number you wish to be converted into roman numerals")
  72.         UserInput = Console.ReadLine()
  73.  
  74.         Select Case UserInput
  75.             Case 1
  76.                 Numeral = "I"
  77.             Case 5
  78.                 Numeral = "V"
  79.             Case 10
  80.                 Numeral = "X"
  81.             Case 50
  82.                 Numeral = "L"
  83.             Case 100
  84.                 Numeral = "C"
  85.             Case 500
  86.                 Numeral = "D"
  87.             Case 1000
  88.                 Numeral = "M"
  89.         End Select
  90.  
  91.         Console.WriteLine(Numeral)
  92.         Console.ReadKey()
  93.  
  94.     End Sub
  95.  
  96.     Sub Buissness()
  97.         Dim CostPerNight As Integer
  98.         Dim Distance As Integer
  99.  
  100.         Console.WriteLine("Please input the distance")
  101.         Distance = Console.ReadLine()
  102.         Console.WriteLine("Please input the cost per night")
  103.         CostPerNight = Console.ReadLine()
  104.  
  105.         If Distance <= 5 And CostPerNight <= 60 Then
  106.             Console.WriteLine("The company will pay your expenses")
  107.         Else
  108.             Console.WriteLine("The company will not pay your expenses")
  109.         End If
  110.         Console.ReadKey()
  111.     End Sub
  112.  
  113.     Sub SportsClub()
  114.         Dim Membership As String
  115.         Dim Subscription As String
  116.         Dim Age As Integer
  117.         Dim Years As Integer
  118.  
  119.         Console.WriteLine("Please input your age")
  120.         Age = Console.ReadLine()
  121.         Console.WriteLine("Please input the number of years you have been a member for")
  122.         Years = Console.ReadLine()
  123.  
  124.         If Age <= 18 Then
  125.             Membership = "Junior"
  126.             Subscription = "£60 per year"
  127.         ElseIf Age > 18 And Age < 50 Then
  128.             Membership = "Senior"
  129.             Subscription = "£120 per year"
  130.         ElseIf Age >= 50 Then
  131.             Membership = "Veteran"
  132.             Subscription = "£80 per year"
  133.         End If
  134.  
  135.         If Membership = "Junior" And Years >= 2 Then
  136.             Subscription = "£40 per year"
  137.         ElseIf Membership = "Senior" And Years >= 10 Then
  138.             Subscription = "£90 per year"
  139.         End If
  140.  
  141.         Console.WriteLine("Your membership is " & Membership)
  142.         Console.WriteLine("Your Subscription is " & Subscription)
  143.         Console.ReadKey()
  144.     End Sub
  145.  
  146.     Sub RockPaperScissors()
  147.         Dim UserInput As Integer
  148.         Dim RandBotGuess As Integer = Int(Rnd() * 3) + 1
  149.         Dim PlayAgain As String
  150.  
  151.         Console.WriteLine("Rock. Paper or Scissors? (1, 2 or 3)")
  152.         UserInput = Console.ReadLine()
  153.  
  154.         Console.WriteLine()
  155.         Console.WriteLine("You Guessed " & UserInput)
  156.         Console.WriteLine("The Bot Guessed " & RandBotGuess)
  157.         Console.WriteLine()
  158.  
  159.  
  160.         If UserInput = 1 And RandBotGuess = 3 Then
  161.             Console.WriteLine("You Win!")
  162.         ElseIf UserInput = 2 And RandBotGuess = 1 Then
  163.             Console.WriteLine("You Win!")
  164.         ElseIf UserInput = 3 And RandBotGuess = 2 Then
  165.             Console.WriteLine("You win!")
  166.         ElseIf UserInput = RandBotGuess Then
  167.             Console.WriteLine("Draw!")
  168.         Else
  169.             Console.WriteLine("The Bot Wins!")
  170.         End If
  171.  
  172.         Console.WriteLine("Would you like to play again? (y/n)")
  173.         PlayAgain = Console.ReadLine()
  174.  
  175.         If PlayAgain = "y" Then
  176.             RockPaperScissors()
  177.         End If
  178.  
  179.     End Sub
  180.  
  181.     Sub LogicGates()
  182.         Dim UserInput As String
  183.         Dim FirstInput As Integer
  184.         Dim SecondInput As Integer
  185.         Dim Result As Integer = 0
  186.         Dim RunAgain As String
  187.  
  188.         Console.WriteLine("Please input the logic gate you wish to use (OR, AND or XOR)")
  189.         UserInput = Console.ReadLine()
  190.         Console.WriteLine("Please Enter the first input")
  191.         FirstInput = Console.ReadLine()
  192.         Console.WriteLine("Please enter the sencond input")
  193.         SecondInput = Console.ReadLine()
  194.  
  195.         If UserInput = "OR" Then
  196.             If FirstInput Or SecondInput = 1 Then
  197.                 Result = 1
  198.             End If
  199.         End If
  200.  
  201.         If UserInput = "AND" Then
  202.             If FirstInput = 1 And SecondInput = 1 Then
  203.                 Result = 1
  204.             End If
  205.         End If
  206.  
  207.         If UserInput = "Xor" Then
  208.             If FirstInput = 1 And SecondInput = 0 Then
  209.                 Result = 1
  210.             ElseIf FirstInput = 0 And SecondInput = 1 Then
  211.                 Result = 1
  212.             End If
  213.         End If
  214.  
  215.         Console.WriteLine("Result = " & Result)
  216.         Console.WriteLine("Would you like to run this program again? (y/n)")
  217.         RunAgain = Console.ReadLine()
  218.         If RunAgain = "y" Then
  219.             LogicGates()
  220.         End If
  221.     End Sub
  222.  
  223.     Sub AdvancedNumerals()
  224.         Dim UserInput As Integer
  225.         Dim Numeral As String
  226.         Dim NumLen As Integer
  227.  
  228.  
  229.         Console.WriteLine("Please input a number between 1-50 that you would like to convert into roman numerals")
  230.         UserInput = Console.ReadLine()
  231.         NumLen = Len(UserInput)
  232.  
  233.         For i = 1 To NumLen
  234.  
  235.  
  236.             Select Case UserInput
  237.                 Case 1
  238.                     Numeral = "I"
  239.                 Case 5
  240.                     Numeral = "V"
  241.                 Case 10
  242.                     Numeral = "X"
  243.                 Case 50
  244.                     Numeral = "L"
  245.             End Select
  246.         Next
  247.     End Sub
  248.  
  249. End Module
Advertisement
Add Comment
Please, Sign In to add comment