Advertisement
Guest User

Untitled

a guest
May 24th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 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. using static System.Console;
  7.  
  8. namespace ISPIT
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. byte i;
  15. float x,y;
  16. string pocetak;
  17. Poc:
  18. IspisIzbornika();
  19. i = Cijeli();
  20. x = Realan();
  21. switch(i)
  22. {
  23. case 1:
  24. y = 3 * x + 4;
  25. WriteLine("y = 3*{0}+4 = {1}",x,y);
  26. break;
  27. case 2:
  28. y = x / 3 - 4;
  29. WriteLine("y = {0}/3-4 = {1}",x,y);
  30. break;
  31. }
  32. WriteLine("Želiš li još računati? (d/n): ");
  33. pocetak=ReadLine();
  34. if (pocetak.Contains('d'))
  35. {
  36. goto Poc;
  37. }
  38. else
  39. {
  40. Kraj();
  41. }
  42. }
  43. static void Kraj()
  44. {
  45. WriteLine("\n\n\nMihael Tibinac, 3. elektrotehničar, 24.5.2019.");
  46. ReadKey();
  47. }
  48. static void IspisIzbornika()
  49. {
  50. WriteLine("xxxxxxxxxxxxxxxxxxxxxxx\n 1. Formula y=3*x+4\n 2. Formula y=x/3-4\nxxxxxxxxxxxxxxxxxxxxxxx\n\nKoju formulu želiš?");
  51. }
  52. static byte Cijeli()
  53. {
  54. byte i;
  55. vrati:
  56. WriteLine("Cijeli broj: ");
  57. bool provjera = byte.TryParse(ReadLine(), out i);
  58. if (!(provjera && i > 0 && i < 3))
  59. {
  60. WriteLine("Mora biti broj izmedju 1 i 2!");
  61. goto vrati;
  62. }
  63. return i;
  64. }
  65. static float Realan()
  66. {
  67. float x;
  68. vrati:
  69. WriteLine("Unesi varijablu x: ");
  70. bool provjera = float.TryParse(ReadLine(), out x);
  71. if (!(provjera))
  72. {
  73. WriteLine("Mora biti realan broj");
  74. goto vrati;
  75. }
  76. return x;
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement