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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string wybor;
- do
- {
- Console.WriteLine("Co chcesz zrobić A - f. kwadratowa, B - silnia, C - chce zakończyć program");
- wybor = Console.ReadLine();
- switch (wybor)
- {
- case "A":
- int a, b, c, delta;
- double x1, x2;
- Console.WriteLine("Podaj wartość a");
- bool oka = Int32.TryParse(Console.ReadLine(), out a);
- Console.WriteLine("Podaj wartość b");
- bool okb = Int32.TryParse(Console.ReadLine(), out b);
- Console.WriteLine("Podaj wartość c");
- bool okc = Int32.TryParse(Console.ReadLine(), out c);
- if ((oka == true) && (okb == true) && (okc == true))
- {
- delta = b * b - (4 * a * c);
- Console.WriteLine("Delta wynosi: " + delta);
- if (delta > 0)
- {
- x1 = (-b - Math.Sqrt(delta)) / (2 * a);
- x2 = (-b + Math.Sqrt(delta)) / (2 * a);
- Console.WriteLine("x1: " + x1 + " x2: " + x2);
- }
- else if (delta == 0)
- {
- x1 = (-b - Math.Sqrt(delta)) / (2 * a);
- Console.WriteLine("x1: " + x1);
- }
- else
- {
- Console.WriteLine("Brak miejsc zerowych");
- }
- }
- else
- {
- Console.WriteLine("Błąd podaj cyf");
- }
- Console.ReadKey();
- break;
- case "B":
- int liczba;
- int silnia = 1;
- Console.WriteLine("Podaj wartość a");
- bool okliczba = Int32.TryParse(Console.ReadLine(), out liczba);
- for (int i = 1; i <= liczba; i++)
- {
- silnia = silnia * i;
- }
- Console.WriteLine("Silnia liczby " + liczba + " wynosi: " + silnia);
- Console.ReadKey();
- break;
- case "C":
- break;// koniec petli
- break;// konciec case
- default:
- Console.WriteLine("zly wybor:P");
- break;
- }
- }
- while (wybor != "C");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement