Klavyeden girilen 2
sayının toplamını bulan programı yazınız.
static int sayı1, sayı2, toplam;
static void giriş()
{
Console.Clear();
Console.Write("1.Sayıyı Gir = ");
sayı1 = Convert.ToInt16(Console.ReadLine());
Console.Write("2.Sayıyı Gir = ");
sayı2 = Convert.ToInt16(Console.ReadLine());
}
static void işlem()
{
toplam = sayı1 + sayı2;
}
static void sonuç()
{
Console.Write(sayı1
+ " + " + sayı2 + " = " + toplam);
}
static void Main(string[]
args)
{
giriş();
işlem();
sonuç();
Console.ReadKey();
}
Klavyeden girilen 2 sayıyı kullanıcının
isteğine göre 4 işlem uygulayan programı yazınız.
static int sayı1,
sayı2, sonuç, seçim;
static void menü()
{
Console.BackgroundColor
= ConsoleColor.Yellow;
Console.ForegroundColor
= ConsoleColor.Blue;
Console.Clear();
Console.CursorTop
= 5;Console.CursorLeft = 30;
Console.Write("ANA MENÜ");
Console.CursorTop
= 7; Console.CursorLeft = 30;
Console.Write("1-TOPLAMA");
Console.CursorTop
= 8; Console.CursorLeft = 30;
Console.Write("2-ÇIKARMA");
Console.CursorTop
= 9; Console.CursorLeft = 30;
Console.Write("3-ÇARPMA");
Console.CursorTop
= 10; Console.CursorLeft = 30;
Console.Write("4-BÖLME");
Console.CursorTop
= 11; Console.CursorLeft = 30;
Console.Write("5-ÇIKIŞ");
Console.CursorTop
= 13; Console.CursorLeft = 30;
Console.Write("SEÇİMİNİZ [1-5] = ");
seçim = Convert.ToInt16(Console.ReadLine());
}
static void giriş()
{
Console.Clear();
Console.Write("1.Sayıyı Gir = ");
sayı1 = Convert.ToInt16(Console.ReadLine());
Console.Write("2.Sayıyı Gir = ");
sayı2 = Convert.ToInt16(Console.ReadLine());
}
static void toplama()
{
sonuç = sayı1 + sayı2;
Console.WriteLine(sayı1
+ " + " + sayı2 + " = " + sonuç);
}
static void çıkarma()
{
sonuç = sayı1 - sayı2;
Console.WriteLine(sayı1
+ " - " + sayı2 + " = " + sonuç);
}
static void çarpma()
{
sonuç = sayı1 * sayı2;
Console.WriteLine(sayı1
+ " * " + sayı2 + " = " + sonuç);
}
static void bölme()
{
sonuç = sayı1 / sayı2;
Console.WriteLine(sayı1
+ " / " + sayı2 + " = " + sonuç);
}
static void Main(string[]
args)
{
start:
menü();
if
(seçim == 5) Environment.Exit(0);
giriş();
if
(seçim == 1) toplama();
if
(seçim == 2) çıkarma();
if
(seçim == 3) çarpma();
if
(seçim == 4) bölme();
Console.Write("Ana Menüye Dönmek İçin Bir Tuşa Basınız");
Console.ReadKey();
goto
start;
}
Klavyeden 5 öğrencinin adısoyadı ve notu
giriliyor. Adısoyadına ve notuna göre sıralayıp listeleyen programı yazınız.
static
string[] isim = new
string[6];
static
int[] notu = new
int[6];
static
string gisim;
static
int gnotu;
static void giriş()
{
for (int sayaç = 1; sayaç < 6; sayaç++)
{
Console.Write(sayaç
+ ".Kişi =");
isim[sayaç] = Console.ReadLine();
Console.Write(isim[sayaç]
+ "'nin Notu =");
notu[sayaç] = Convert.ToInt16(Console.ReadLine());
}
}
static void isimsıralama()
{
for
(int i = 1; i < 6; i++)
for
(int k = 1; k < 6; k++)
if
(string.Compare(isim[i], isim[k]) == -1)
{
gisim = isim[i];
isim[i] = isim[k];
isim[k] = gisim;
gnotu = notu[i];
notu[i] = notu[k];
notu[k] = gnotu;
}
}
static void notsıralama()
{
for
(int i = 1; i < 6; i++)
for
(int k = 1; k < 6; k++)
if
(notu[i] < notu[k])
{
gisim = isim[i];
isim[i] = isim[k];
isim[k] = gisim;
gnotu = notu[i];
notu[i] = notu[k];
notu[k] = gnotu;
}
}
static void listeleme()
{
Console.WriteLine("İsimler
Notlar");
for
(int sayaç = 1; sayaç < 6; sayaç++)
{
Console.Write(isim[sayaç]);
Console.CursorLeft
= 15;
Console.WriteLine(notu[sayaç]);
}
Console.ReadKey();
}
static void Main(string[]
args)
{
giriş();
isimsıralama();
listeleme();
notsıralama();
listeleme();
}
Hiç yorum yok:
Yorum Gönder