Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace filipworkout
- {
- class Program
- {
- struct Pretplata
- {
- public string kupac;
- public int godinaRodenja;
- public double uplata;
- }
- static Pretplata[] Red(Pretplata[] niz)
- {
- Pretplata[] redak = niz;
- Random r = new Random();
- for (int i = 0; i < redak.Length; i++)
- {
- do
- {
- Console.WriteLine("Unesite ime {0}. kupca:", i + 1);
- redak[i].kupac = Console.ReadLine();
- } while (redak[i].kupac.Trim() == "");
- redak[i].godinaRodenja = r.Next(1940, 2018);
- do
- {
- Console.WriteLine("Unesite uplatu {0} kupca:", i+1);
- redak[i].uplata = double.Parse(Console.ReadLine());
- } while (redak[i].uplata <1);
- }
- return redak;
- }
- static void ListaSvih(Pretplata[] Niz)
- {
- for (int i =0; i < Niz.Length; i++)
- {
- Console.WriteLine(Niz[i].kupac,Niz[i].godinaRodenja,Niz[i].uplata);
- }
- }
- static void Main(string[] args)
- {
- int broj;
- do
- {
- Console.WriteLine("Unesite broj pretplata:");
- broj = int.Parse(Console.ReadLine());
- } while (broj % 2 == 1 || broj < 1 || broj > 50);
- Pretplata[] noviniz = new Pretplata[broj]; //deklariranje novog niza (duzina kolko upisemo) - prazan niz
- noviniz = Red(noviniz);
- ListaSvih(noviniz);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement