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 prosty_kalkulator
- {
- class Program
- {
- static void Dodaj()
- {
- try
- {
- string argument1, argument2;
- Console.Write("Podaj argument 1: ");
- argument1 = Console.ReadLine();
- int arg1 = Convert.ToInt32(argument1);
- Console.Write("Podaj argument 2: ");
- argument2 = Console.ReadLine();
- int arg2 = Convert.ToInt32(argument2);
- int wynik = arg1 + arg2;
- Console.WriteLine("wynik : " + wynik);
- }
- catch (FormatException)
- {
- Console.WriteLine("NIE WOLNO PODAWAĆ LITER!!!!!!!!!");
- }
- Console.ReadKey();
- }
- //**************************************************************************************************************
- static void Odejmij()
- {
- try
- {
- string argument1, argument2;
- Console.Write("Podaj argument 1 : ");
- argument1 = Console.ReadLine();
- int arg1 = Convert.ToInt32(argument1);
- Console.Write("Podaj argument 2 : ");
- argument2 = Console.ReadLine();
- int arg2 = Convert.ToInt32(argument2);
- int wynik = arg1 - arg2;
- Console.WriteLine("wynik : " + wynik);
- }
- catch (FormatException)
- {
- Console.WriteLine("NIE WOLNO PODAWAĆ LITER!!!!!!!!!");
- }
- Console.ReadKey();
- }
- //**************************************************************************************************************
- static void Pomnuż()
- {
- try
- {
- string argument1, argument2;
- Console.Write("Podaj argument 1 : ");
- argument1 = Console.ReadLine();
- int arg1 = Convert.ToInt32(argument1);
- Console.Write("Podaj argument 2 : ");
- argument2 = Console.ReadLine();
- int arg2 = Convert.ToInt32(argument2);
- int wynik = arg1 * arg2;
- Console.WriteLine("wynik : " + wynik);
- }
- catch (FormatException)
- {
- Console.WriteLine("NIE WOLNO PODAWAĆ LITER!!!!!!!!!");
- }
- Console.ReadKey();
- }
- //**************************************************************************************************************
- public static void Podziel()
- {
- try
- {
- string argument1, argument2;
- Console.Write("Podaj argument 1 : ");
- argument1 = Console.ReadLine();
- int arg1 = Convert.ToInt32(argument1);
- Console.Write("Podaj argument 2 : ");
- argument2 = Console.ReadLine();
- int arg2 = Convert.ToInt32(argument2);
- int sprawdzenie = 30 / arg2;
- double wynik = (double)arg1 / arg2;
- Console.WriteLine("wynik : " + wynik);
- }
- catch (DivideByZeroException)
- {
- Console.WriteLine("NIE WOLNO DZIELIĆ PRZEZ 0!!!!!!!!!!!!!!!");
- }
- catch (FormatException)
- {
- Console.WriteLine("NIE WOLNO PODAWAĆ LITER!!!!!!!!!");
- }
- Console.ReadKey();
- }
- //**************************************************************************************************************
- static void Main(string[] args)
- {
- string lacwejsciowy = " ";
- do
- {
- Console.Clear();
- Console.WriteLine("****************** KALKULATOR **************");
- Console.WriteLine("* *");
- Console.WriteLine("* Dodawanie - nacisnij + *");
- Console.WriteLine("* Odejmowanie - nacisnij - *");
- Console.WriteLine("* Mnożenie - nacisnij * *");
- Console.WriteLine("* Dzielenie - nacisnij / *");
- Console.WriteLine("* Koniec - nacisnij k *");
- Console.WriteLine("* *");
- Console.WriteLine("********************************************");
- lacwejsciowy = Console.ReadLine();
- Console.Clear();
- //**************************************************************************************************************
- switch (lacwejsciowy)
- {
- case "+":
- {
- Console.WriteLine("---------------------------");
- Console.WriteLine("**** Wybrano dodawanie ****");
- Console.WriteLine("---------------------------");
- Dodaj();
- break;
- }
- case "-":
- {
- Console.WriteLine("----------------------------");
- Console.WriteLine("**** Wybrano odejmowanie ****");
- Console.WriteLine("----------------------------");
- Odejmij();
- break;
- }
- case "*":
- {
- Console.WriteLine("--------------------------");
- Console.WriteLine("**** Wybrano mnożenie ****");
- Console.WriteLine("--------------------------");
- Pomnuż();
- break;
- }
- case "/":
- {
- Console.WriteLine("---------------------------");
- Console.WriteLine("**** Wybrano dzielenie ****");
- Console.WriteLine("---------------------------");
- Podziel();
- break;
- }
- }
- //**************************************************************************************************************
- } while (lacwejsciowy != "k");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement