Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Lekcja8
- {
- public static void Main(string[] args)
- {
- System.Console.WriteLine("Cześć! Jak masz na imię?");
- string? imie = Console.ReadLine();
- if (imie == null) return;
- System.Console.WriteLine($"Witaj {imie.ToUpper()}. Co Chcesz robić?: ");
- System.Console.WriteLine("a. dodawanie \nb. odejmowanie \nc. mnożenie \nd. dzielenie");
- string? wybor = Console.ReadLine();
- if (wybor == null) return;
- Console.Write("Podaj pierwszą liczbę: ");
- int liczba1;
- try
- {
- liczba1 = int.Parse(Console.ReadLine()!);
- }
- catch (FormatException format)
- {
- System.Console.WriteLine("Podana wartość nie jest liczbą");
- System.Console.WriteLine(format.Message);
- return;
- }
- catch (Exception)
- {
- System.Console.WriteLine("Coś poszlo nie tak");
- return;
- }
- int liczba2;
- bool parsowanie = int.TryParse(Console.ReadLine(), out liczba2);
- if (!parsowanie)
- {
- System.Console.WriteLine("To nie jest liczba");
- return;
- }
- System.Console.WriteLine($"Podałeś liczbę: {liczba1}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement