//1. Stwórz klasę kalkulator, która pozwoli dodawać, odejmować, mnożyć i dzielić.
//Jej dodatkową funkcjonalnością będzie metoda pokazLiczbyCalkowite,
//która pozwoli pokazać liczby całkowite od 1 do wartości podanej jako argument metody.
//Czyli pokazLiczbyCalkowite(10) pokaze liczby od 1 do 10
using System;
namespace dzien2
{
class Kalkulator
{
public int _x;
public int _y;
public int Dodawanie(int x, int y)
{
this._x = x;
this._y = y;
return x + y;
}
public int Odejmowanie(int x, int y)
{
this._x = x;
this._y = y;
return x - y;
}
public int Dzielenie(int x, int y)
{
this._x = x;
this._y = y;
return x / y;
}
public int Mnozenie(int x, int y)
{
this._x = x;
this._y = y;
return x * y;
}
public string PokazLiczbyCalkowite(int x)
{
if (x > 0 && x%2 == 0)
{
return "PARZYSTE";
}
else
{
return "NIEPARZYSTE";
}
}
public string PokazLiczbyCalkowite10()
{
return "1,2,3,4,5,6,7,8,9,10";
}
}
class Program
{
static void Main(string[] args)
{
Kalkulator suma
= new Kalkulator
();
Console.WriteLine("Dodawanie liczb 2 i 2 = " + suma.Dodawanie(2,2));
Kalkulator odjemnik
= new Kalkulator
();
Console.WriteLine("Odejmowanie liczb 2 i 2 = " + odjemnik.Odejmowanie(2, 2));
Kalkulator dzielnik
= new Kalkulator
();
Console.WriteLine("Dzielenie liczb 2 i 2 = " + dzielnik.Dzielenie(2, 2));
Kalkulator powielacz
= new Kalkulator
();
Console.WriteLine("Mnozenie 2 i 2 = " + powielacz.Mnozenie(2, 2));
Kalkulator Calkowite
= new Kalkulator
();
Console.WriteLine("Podaj liczbe calkowite: ");
int v = Convert.ToInt32( Console.ReadLine());
Console.WriteLine(Calkowite.PokazLiczbyCalkowite(v));
Kalkulator Kolejne
= new Kalkulator
();
Console.WriteLine(Kolejne.PokazLiczbyCalkowite10());
Console.ReadKey();
}
}
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}