Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. namespace filipworkout
  2. {
  3. class Program
  4. {
  5. struct Pretplata
  6. {
  7. public string kupac;
  8. public int godinaRodenja;
  9. public double uplata;
  10. }
  11.  
  12. static Pretplata[] Red(Pretplata[] niz)
  13.  
  14. {
  15. Pretplata[] redak = niz;
  16. Random r = new Random();
  17.  
  18. for (int i = 0; i < redak.Length; i++)
  19. {
  20. do
  21. {
  22. Console.WriteLine("Unesite ime {0}. kupca:", i + 1);
  23. redak[i].kupac = Console.ReadLine();
  24. } while (redak[i].kupac.Trim() == "");
  25.  
  26. redak[i].godinaRodenja = r.Next(1940, 2018);
  27.  
  28. do
  29. {
  30. Console.WriteLine("Unesite uplatu {0} kupca:", i+1);
  31. redak[i].uplata = double.Parse(Console.ReadLine());
  32. } while (redak[i].uplata <1);
  33.  
  34. }
  35. return redak;
  36. }
  37.  
  38. static void ListaSvih(Pretplata[] Niz)
  39. {
  40. for (int i =0; i < Niz.Length; i++)
  41. {
  42. Console.WriteLine(Niz[i].kupac,Niz[i].godinaRodenja,Niz[i].uplata);
  43. }
  44. }
  45.  
  46. static void Main(string[] args)
  47. {
  48. int broj;
  49.  
  50. do
  51. {
  52. Console.WriteLine("Unesite broj pretplata:");
  53. broj = int.Parse(Console.ReadLine());
  54. } while (broj % 2 == 1 || broj < 1 || broj > 50);
  55.  
  56. Pretplata[] noviniz = new Pretplata[broj]; //deklariranje novog niza (duzina kolko upisemo) - prazan niz
  57.  
  58. noviniz = Red(noviniz);
  59. ListaSvih(noviniz);
  60. }
  61. }
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement