Lynix_

H/W 5

Nov 8th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Module Module1
  2.  
  3.     Sub Main()
  4.         'Arithmetic()
  5.        'Geometric()
  6.        Triangular()
  7.     End Sub
  8.  
  9.     Sub Arithmetic()
  10.         Dim CommonDifference As Integer
  11.         Dim Output As Integer = 0
  12.  
  13.         Console.WriteLine("Please enter the common difference")
  14.         CommonDifference = Console.ReadLine()
  15.  
  16.         For i = 1 To 20
  17.             Console.WriteLine(Output)
  18.             Output = Output + CommonDifference
  19.         Next
  20.         Console.ReadKey()
  21.     End Sub
  22.  
  23.     Sub Geometric()
  24.         Dim CommonRatio As Integer
  25.         Dim Output As Integer
  26.         Dim FirstValue As Integer
  27.         Dim Value As Integer
  28.  
  29.         Console.WriteLine("Please input the common ratio")
  30.         CommonRatio = Console.ReadLine()
  31.         Console.WriteLine("Please enter the first value of the term")
  32.         FirstValue = Console.ReadLine()
  33.         Value = FirstValue
  34.  
  35.         For i = 1 To 20
  36.             Output = Value * CommonRatio
  37.             Console.WriteLine(Output)
  38.             Value = Output
  39.         Next
  40.  
  41.         Console.ReadKey()
  42.     End Sub
  43.  
  44.     Sub Triangular()
  45.         Dim FirstValue As Integer
  46.         Dim Value As Integer
  47.         Dim Output As Integer
  48.         Dim X As Integer = 1
  49.         Dim Y As Integer = 1
  50.         Console.WriteLine("Please input the first value")
  51.         FirstValue = Console.ReadLine()
  52.         Value = FirstValue
  53.  
  54.         For i = 1 To 20
  55.             Output = Value * (Value + 1) / 2
  56.             Console.WriteLine(Output)
  57.  
  58.             For j = 1 To Value
  59.  
  60.                 Console.Write("@")
  61.  
  62.                 If Y = j Then
  63.                     Console.WriteLine()
  64.                     Y = 0
  65.                 End If
  66.                 Y = Y + 1
  67.             Next
  68.  
  69.             Console.WriteLine()
  70.             Value = Value + 1
  71.         Next
  72.  
  73.         Console.ReadKey()
  74.     End Sub
  75. End Module
Advertisement
Add Comment
Please, Sign In to add comment