Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static string zbir(int zb)
- {
- string poruka;
- poruka = ("Zbir vasih ocenaje " + zb);
- return poruka;
- }
- static string prosek(int pr)
- {
- string poruka;
- poruka = ("Prosek vasih ocena je " + pr);
- return poruka;
- }
- static void Main(string[] args)
- {
- int n = 0;
- int pr = 0;
- int zb = 0;
- int y = 0;
- Console.WriteLine("Unesite broj predmeta koje imate!");
- n = Convert.ToInt32(Console.ReadLine());
- int[] a = new int[n];
- for (int i = 0; i < n; i++)
- {
- Console.WriteLine("unesite ocenu za predmet");
- try
- {
- a[i] = Convert.ToInt32(Console.ReadLine());
- }
- catch
- {
- Console.WriteLine("Uneli ste tekst, molimo vas unesite broj");
- Console.WriteLine();
- i--;
- }
- }
- Console.WriteLine("Za racunanje proseka stisnite slovo 'P'!");
- Console.WriteLine("Za racunanje zbira pritisnite slovo 'Z'!");
- ConsoleKeyInfo input = Console.ReadKey();
- if (input.KeyChar != 'z')
- {
- for (int i = 0; i < n; i++)
- {
- y = y + a[i];
- }
- pr = y / n;
- Console.WriteLine(prosek(pr));
- Console.WriteLine("Da restartujete program pritisnite slovo 'R'.");
- ConsoleKeyInfo input1 = Console.ReadKey();
- }
- if (input.KeyChar != 'p')
- {
- for (int i = 0; i < n; i++)
- {
- zb = zb + a[i];
- }
- Console.WriteLine(zbir(zb));
- Console.WriteLine("Da restartujete program pritisnite slovo 'R'.");
- ConsoleKeyInfo input1 = Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement