Advertisement
Guest User

Untitled

a guest
Jan 13th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static string zbir(int zb)
  12. {
  13. string poruka;
  14. poruka = ("Zbir vasih ocenaje " + zb);
  15. return poruka;
  16. }
  17. static string prosek(int pr)
  18. {
  19. string poruka;
  20. poruka = ("Prosek vasih ocena je " + pr);
  21. return poruka;
  22. }
  23.  
  24. static void Main(string[] args)
  25. {
  26. int n = 0;
  27. int pr = 0;
  28. int zb = 0;
  29. int y = 0;
  30.  
  31. Console.WriteLine("Unesite broj predmeta koje imate!");
  32. n = Convert.ToInt32(Console.ReadLine());
  33. int[] a = new int[n];
  34. for (int i = 0; i < n; i++)
  35. {
  36.  
  37. Console.WriteLine("unesite ocenu za predmet");
  38.  
  39. try
  40. {
  41. a[i] = Convert.ToInt32(Console.ReadLine());
  42. }
  43. catch
  44. {
  45. Console.WriteLine("Uneli ste tekst, molimo vas unesite broj");
  46. Console.WriteLine();
  47. i--;
  48.  
  49. }
  50. }
  51.  
  52. Console.WriteLine("Za racunanje proseka stisnite slovo 'P'!");
  53. Console.WriteLine("Za racunanje zbira pritisnite slovo 'Z'!");
  54. ConsoleKeyInfo input = Console.ReadKey();
  55.  
  56. if (input.KeyChar != 'z')
  57. {
  58. for (int i = 0; i < n; i++)
  59. {
  60. y = y + a[i];
  61. }
  62. pr = y / n;
  63. Console.WriteLine(prosek(pr));
  64. Console.WriteLine("Da restartujete program pritisnite slovo 'R'.");
  65. ConsoleKeyInfo input1 = Console.ReadKey();
  66. }
  67. if (input.KeyChar != 'p')
  68. {
  69. for (int i = 0; i < n; i++)
  70. {
  71. zb = zb + a[i];
  72. }
  73. Console.WriteLine(zbir(zb));
  74. Console.WriteLine("Da restartujete program pritisnite slovo 'R'.");
  75. ConsoleKeyInfo input1 = Console.ReadKey();
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement