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 SimpleCalculator
- {
- class kalkulator
- {
- static void Main(string[] args)
- {
- int dzialanie = 0;
- double result = 0;
- Console.WriteLine("Podaj liczbę pierwszą :");
- int pierwsza = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Podaj liczbę drugą :");
- int druga = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Co chcesz zrobic? + (dodac), - (odjac), * (pomnozyc), / (podzielic)? :");
- string opcja = Console.ReadLine();
- if (opcja == "+" || opcja == "dodac")
- {
- dzialanie = 1;
- }
- else if (opcja == "-" || opcja == "odjac")
- {
- dzialanie = 2;
- }
- else if (opcja == "*" || opcja == "pomnozyc")
- {
- dzialanie = 3;
- }
- else if (opcja == "/" || opcja == "podzielic")
- {
- dzialanie = 4;
- }
- switch (dzialanie)
- {
- case 1:
- result = pierwsza + druga;
- break;
- case 2:
- result = pierwsza - druga;
- break;
- case 3:
- result = pierwsza * druga;
- break;
- case 4:
- result = pierwsza / druga;
- break;
- }
- Console.WriteLine("Wynik: " + pierwsza + " " + opcja + " " + druga + " = " + result + ".");
- Console.WriteLine("");
- Console.WriteLine("");
- Console.WriteLine("Aby wyłączyc wcisnik klawisz 'q', aby kontynuowac wcisnij dowolny klawisz");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement