BTTH1
BTTH1
using System;
class Program
{
static void Main(string[]args)
{
string a,c,d,e;
int b;
Console.Write("Nhap ten cua ban: ");
a = Console.ReadLine();
Console.WriteLine("");
Console.Write("Nhap tuoi cua ban: ");
b = int.Parse(Console.ReadLine());
Console.WriteLine("");
Console.Write("Nhap gioi tinh cua ban: ");
c = Console.ReadLine();
Console.WriteLine("");
Console.Write("Nhap nghe nghiep cua ban: ");
d = Console.ReadLine();
Console.WriteLine("");
Console.Write("Nhap so thich cua ban: ");
e = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine(a);
Console.WriteLine(c);
{
if(b<30)
Console.WriteLine("Ban con qua tre");
}
{
if(d=="Sinh vien")
Console.WriteLine("Ban hay co gang tro thanh sinh vien xuat sac nhe!");
else
Console.Write("Nghe nghiep cua ban cung hay day!");
}
{
if(e == "Lap trinh")
Console.WriteLine("Tuyet voi! Chuc ban se tro thanh lap trinh vien gioi");
if(e == "Choi game")
Console.WriteLine("Day la so thich khong tot");
}
Console.ReadKey();
}
}
Bài 2:
using System;
class Program
{
static void Main(string[]args)
{
float a,b,c,delta,x;
Console.Write("Nhap vao a: ");
a = float.Parse(Console.ReadLine());
Console.WriteLine("");
Console.Write("Nhap vao b: ");
b = float.Parse(Console.ReadLine());
Console.WriteLine("");
Console.Write("Nhap vao c: ");
c = float.Parse(Console.ReadLine());
Console.WriteLine("");
delta = b*b-4*a*c;
x = 0;
if(a==0)
{
Console.WriteLine("day khong la phuong trinh bac hai");
}
else
{
if (delta < 0)
Console.WriteLine("phuong trinh tren vo nghiem");
else if (delta == 0)
{
x = -b/(2*a);
Console.WriteLine("Phuong trinh co nghiem kep"+ x);
}
else
{
Console.WriteLine("Phuong trinh co 2 nghiem phan biet");
double X1=-(b+Math.Sqrt(delta))/(2*a);
double X2=-(b-Math.Sqrt(delta))/(2*a);
Console.WriteLine("Nghiem thu nhat = "+X1);
Console.WriteLine("Nghiem thu hai = "+X2);
}
}
Console.ReadKey();
}
}
Bài 3:
using System;
class Program
{
static void Main(string[] args)
{
int a;
Console.Write("Nhap vao thang: ");
a = int.Parse(Console.ReadLine());
if ((a == 2) || (a == 3) || (a == 4))
Console.WriteLine("Mua Xuan");
if ((a == 5) || (a == 6) || (a == 7))
Console.WriteLine("Mua He");
if ((a == 8) || (a == 9) || (a == 10))
Console.WriteLine("Mua Thu");
if ((a == 11) || (a == 12) || (a == 1))
Console.WriteLine("Mua Dong");
Console.ReadKey();
}
}
Bài 4:
using System;
class Program
{
static void Main(string[]args)
{
string a;
float chiso1, chiso2, soKW, sotien, soKWvuot;
Console.Write("Nhap ten chu ho: ");
a = Console.ReadLine();
Console.Write("Nhap so dien ke thang truoc: ");
chiso1 = float.Parse(Console.ReadLine());
Console.Write("Nhap so dien ke thang nay: ");
chiso2 = float.Parse(Console.ReadLine());
soKW = chiso2 - chiso1;
sotien = 0;
soKWvuot = 0;
if (soKW <= 60)
{
sotien = soKW*5;
Console.WriteLine("So tien thang nay la: "+sotien);
}
else
{
if (61<= soKW && soKW <=160)
{
soKWvuot = soKW - 60;
sotien = 60*5+soKWvuot*8;
Console.WriteLine("So tien thang nay la: "+sotien);
}
else if (161<=soKW)
{
soKWvuot = soKW - 160;
sotien = 60*5+100*8+soKWvuot*10;
Console.WriteLine("So tien thang nay la: "+sotien);
}
}
Console.ReadKey();
}
}