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 ConsoleDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- Console.WriteLine(">>> MENU <<<");
- Console.WriteLine("1 - Dodaj 2 liczby");
- Console.WriteLine("2 - Odejmij 2 liczby");
- Console.WriteLine("3 - Oblicz sume n liczb");
- Console.WriteLine("4 - Oblicz sume liczb dodatnich");
- Console.WriteLine("5 - Koniec");
- int opcja = int.Parse(Console.ReadLine());
- switch (opcja)
- {
- case 1:
- Console.WriteLine("Podaj pierwsza liczbe");
- string liczba1 = Console.ReadLine();
- float a = float.Parse(liczba1);
- Console.WriteLine("Podaj druga liczbe");
- string liczba2 = Console.ReadLine();
- float b = float.Parse(liczba2);
- float suma = a + b;
- Console.WriteLine("Suma podanych liczb to:" + suma);
- Console.WriteLine("");
- break;
- case 2:
- Console.WriteLine("Podaj pierwsza liczbe");
- string liczba1 = Console.ReadLine();
- float a = float.Parse(s: liczba1);
- Console.WriteLine("Podaj druga liczbe");
- string liczba2 = Console.ReadLine();
- float b = float.Parse(s: liczba2);
- float roznica = a - b;
- Console.WriteLine("Roznica podanych liczb to:" - roznica);
- Console.WriteLine("");
- break;
- /* case 3:
- int suma = 0;
- do
- {
- Console.WriteLine("podaj n");
- int dana = int.Parse(Console.ReadLine());
- if (dana == 0)
- break;
- suma += dana;
- Console.WriteLine("twoja suma: \n" + suma);
- } while (true);
- Console.ReadKey();
- */
- case 4:
- Console.WriteLine("Podaj pierwsza liczbe");
- string liczba1 = Console.ReadLine();
- float a = float.Parse(liczba1);
- Console.WriteLine("Podaj druga liczbe");
- string liczba2 = Console.ReadLine();
- float b = float.Parse(liczba2);
- float suma = a + b;
- Console.WriteLine(value: "Wynik z podanych liczb to:" + suma);
- Console.WriteLine("");
- break;
- case ConsoleKey.Escape:
- case 5:
- Environment.Exit(0);
- break;
- default: break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement