Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Kalkulator
- {
- public static void Main(string[] args)
- {
- float liczba1, liczba2;
- System.Console.WriteLine("Podaj pierwszą liczbę");
- liczba1 = float.Parse(Console.ReadLine());
- System.Console.WriteLine("Podaj drugą liczbę");
- liczba2 = float.Parse(Console.ReadLine());
- System.Console.WriteLine("1. Dodawanie\n2. Odejmowanie\n3. Mnożenie\n4. Dzielenie");
- int operacja = int.Parse(Console.ReadLine());
- if(operacja == 1)
- {
- System.Console.WriteLine($"{liczba1} + {liczba2} = {liczba1 + liczba2}");
- }
- else if(operacja == 2)
- {
- // odejmowanie
- }
- else if (operacja == 3)
- {
- //mnożenie
- }
- else if (operacja == 4)
- {
- if (liczba2 == 0)
- {
- System.Console.WriteLine("Nie mogę dzielić przez zero");
- }
- else
- {
- System.Console.WriteLine($"{liczba1} / {liczba2} = {liczba1 / liczba2}");
- }
- }
- else
- {
- System.Console.WriteLine("Nioe znam takiego działania");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement