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;
- using static System.Console;
- namespace ISPIT
- {
- class Program
- {
- static void Main(string[] args)
- {
- byte i;
- float x,y;
- string pocetak;
- Poc:
- IspisIzbornika();
- i = Cijeli();
- x = Realan();
- switch(i)
- {
- case 1:
- y = 3 * x + 4;
- WriteLine("y = 3*{0}+4 = {1}",x,y);
- break;
- case 2:
- y = x / 3 - 4;
- WriteLine("y = {0}/3-4 = {1}",x,y);
- break;
- }
- WriteLine("Želiš li još računati? (d/n): ");
- pocetak=ReadLine();
- if (pocetak.Contains('d'))
- {
- goto Poc;
- }
- else
- {
- Kraj();
- }
- }
- static void Kraj()
- {
- WriteLine("\n\n\nMihael Tibinac, 3. elektrotehničar, 24.5.2019.");
- ReadKey();
- }
- static void IspisIzbornika()
- {
- WriteLine("xxxxxxxxxxxxxxxxxxxxxxx\n 1. Formula y=3*x+4\n 2. Formula y=x/3-4\nxxxxxxxxxxxxxxxxxxxxxxx\n\nKoju formulu želiš?");
- }
- static byte Cijeli()
- {
- byte i;
- vrati:
- WriteLine("Cijeli broj: ");
- bool provjera = byte.TryParse(ReadLine(), out i);
- if (!(provjera && i > 0 && i < 3))
- {
- WriteLine("Mora biti broj izmedju 1 i 2!");
- goto vrati;
- }
- return i;
- }
- static float Realan()
- {
- float x;
- vrati:
- WriteLine("Unesi varijablu x: ");
- bool provjera = float.TryParse(ReadLine(), out x);
- if (!(provjera))
- {
- WriteLine("Mora biti realan broj");
- goto vrati;
- }
- return x;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement