Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int wyjscie = 1;
- while (wyjscie==1)
- {
- Console.WriteLine("1. Dodawanie");
- Console.WriteLine("2. Odejmowanie");
- Console.WriteLine("3. Mnożenie");
- Console.WriteLine("4. Dzielenie");
- Console.WriteLine("5. Potęgowanie Math.pow");
- Console.WriteLine("6. Potęgowanie własne");
- Console.WriteLine("7. Silnia");
- Console.WriteLine("8. Pole Kwadratu");
- Console.WriteLine("9. Pole Prostokąta");
- Console.WriteLine("10. Pole trójkata");
- Console.WriteLine("11. Objętość prostopadłościanu");
- Console.WriteLine("12. Wyjście");
- int wybor = int.Parse(Console.ReadLine());
- Console.Clear();
- if (wybor == 12) { break; }
- else if (wybor == 7) { Console.WriteLine("Z jakiej liczby chcesz obliczyć silnie?:"); int c = int.Parse(Console.ReadLine()); int wynik = silnia(c); Console.WriteLine(wynik); }
- else if (wybor == 8) { Console.WriteLine("Podaj długość boku kwadratu:"); int bok = int.Parse(Console.ReadLine()); int wynik = mnozenie(bok, bok); Console.WriteLine("Pole kwadratu to: " + wynik + "^2"); }
- else if (wybor == 9)
- {
- Console.WriteLine("Podaj długość pierwszego boku:"); int bok1 = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj długość drugiego boku:"); int bok2 = int.Parse(Console.ReadLine()); int wynik = mnozenie(bok1, bok2); Console.WriteLine(wynik);
- }
- else if (wybor == 10) { Console.WriteLine("Podaj długość boku:"); double boka = double.Parse(Console.ReadLine()); Console.WriteLine("Podaj długość wysokości trójkąta:"); double h = double.Parse(Console.ReadLine()); double wynik = trojkat(boka, h); Console.WriteLine("Pole trójkąta to: " + wynik + "^2"); }
- else if (wybor == 11) { Console.WriteLine("Podaj długość pierwszego boku:"); int bok1 = int.Parse(Console.ReadLine()); Console.WriteLine("Podaj długośc drugiego boku:"); int bok2 = int.Parse(Console.ReadLine()); Console.WriteLine("Podaj wysokość:"); int wys = int.Parse(Console.ReadLine()); int wynik = prostopadloscian(bok1, bok2, wys); Console.WriteLine("Objętość prostopadłościanu to: " + wynik); }
- else if (wybor == 5|| wybor == 6)
- {
- Console.WriteLine("Z jakiej liczby chcesz policzyć potęgę? :");
- int d = int.Parse(Console.ReadLine());
- Console.WriteLine("Jaki ma być wykładnik? :");
- int e = int.Parse(Console.ReadLine());
- if (wybor == 5) { double wynik = potegowanie1(d, e); Console.WriteLine(wynik); }
- if (wybor == 6) { int wynik = potegowanie2(d, e); Console.WriteLine(wynik); }
- }
- else if (wybor == 1 || wybor == 2 || wybor == 3 || wybor == 4)
- {
- Console.WriteLine("Podaj pierwszą liczbę: ");
- int a = int.Parse(Console.ReadLine());
- Console.WriteLine("Podaj drugą liczbę: ");
- int b = int.Parse(Console.ReadLine());
- if (wybor == 1) { int wynik = dodawanie(a, b); Console.WriteLine(wynik); }
- if (wybor == 2) { int wynik = odejmowanie(a, b); Console.WriteLine(wynik); }
- if (wybor == 3) { int wynik = mnozenie(a, b); Console.WriteLine(wynik); }
- if (wybor == 4)
- { if (b == 0) { Console.WriteLine("nie dziel przez zero"); } else { int wynik = dzielenie(a, b); Console.WriteLine(wynik); } }
- }
- Console.WriteLine();
- Console.ReadKey();
- Console.Clear();
- }
- }
- static int dodawanie(int a, int b)
- { return a + b; }
- static int odejmowanie(int a, int b)
- { return a - b; }
- static int mnozenie(int a, int b)
- { return (a * b); }
- static int dzielenie (int a, int b)
- { return a / b; }
- static double potegowanie1 (double d,double e)
- { return Math.Pow(d, e); }
- static int potegowanie2 (int d, int e)
- { if (e <= 0)
- Console.WriteLine("1");
- int i = 1;
- int c = 1;
- for (i=1; i<=e;i = i++)
- {
- c = c * d;
- i = i + 1;
- }
- if (e > 0)
- Console.WriteLine();
- return c;
- }
- static int silnia(int c)
- { int i = 1;
- int d = 1;
- for (i=1;i<=c;i++)
- { d = d * i; }
- Console.WriteLine();
- return d;
- }
- static double trojkat (double a,double b)
- { double c = 0.5;
- a = a * c;
- return a * b;
- }
- static int prostopadloscian(int a,int b,int c)
- { return a * b * c; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment