Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.15 KB | None | 0 0
  1. Imports Microsoft.VisualBasic.CompilerServices
  2.  
  3. Module Module1
  4.  
  5.     Public Class GodisnjeDoba
  6.         Structure Godina
  7.             Dim mjesec As String
  8.             Dim temperatura As Integer
  9.         End Structure
  10.  
  11.         Function Punjenje(ByRef unos As Godina())
  12.             Dim random1 As Random = New Random()
  13.             For i As Integer = 0 To unos.GetUpperBound(0)
  14.                 Console.Write("Unesite ime mjeseca: ")
  15.                 unos(i).mjesec = Console.ReadLine()
  16.                 unos(i).temperatura = random1.Next(-1, 30)
  17.                 Console.WriteLine()
  18.             Next
  19.             Console.WriteLine()
  20.             Return 0
  21.         End Function
  22.  
  23.         Sub Ispis(ByRef struktura As Godina())
  24.             For Each ulaz In struktura
  25.                 Console.WriteLine("MJESEC: {0}   TEMPERATURA: {1}", ulaz.mjesec, ulaz.temperatura)
  26.             Next
  27.             Console.WriteLine()
  28.         End Sub
  29.  
  30.         Sub MaxIspis(ByRef max As Integer)
  31.             For i As Integer = 1 To max
  32.                 Console.Write("*" & " ")
  33.             Next
  34.             Console.WriteLine()
  35.         End Sub
  36.  
  37.         Function MaxTemp(ByRef max As Integer, ByRef temperatura As Godina()) As Integer
  38.  
  39.             max = temperatura(0).temperatura
  40.             For i As Integer = 0 To temperatura.GetUpperBound(0)
  41.                 If temperatura(i).temperatura > max Then
  42.                     max = temperatura(i).temperatura
  43.                 End If
  44.             Next
  45.             Console.WriteLine()
  46.             Return max
  47.         End Function
  48.  
  49.     End Class
  50.  
  51.     Sub Main()
  52.  
  53.         Dim pozivKlase As GodisnjeDoba = New GodisnjeDoba()
  54.         Dim pozivStrukture As GodisnjeDoba.Godina() = New GodisnjeDoba.Godina(2) {}
  55.         Dim max As Integer
  56.  
  57.         Console.WriteLine("Molimo vas unesite iduće podatke")
  58.         Console.WriteLine()
  59.  
  60.         pozivKlase.Punjenje(pozivStrukture)
  61.         Console.WriteLine()
  62.         pozivKlase.Ispis(pozivStrukture)
  63.         Console.WriteLine()
  64.         pozivKlase.MaxTemp(max, pozivStrukture)
  65.         Console.WriteLine()
  66.         pozivKlase.MaxIspis(max)
  67.  
  68.  
  69.         Console.ReadKey()
  70.     End Sub
  71. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement