Tran Vu Hoang
Tran Vu Hoang
Tên: Trần Vũ Hoàng Nguyễn Hữu Đại Mang Huỳnh Tấn Dũng
BTL1 7,8,9 4,5,6 1,2,3
BTL6 Full
2
Console.WriteLine("-----------------------------");
Console.Write("Nhap ngay: ");
int day = int.Parse(Console.ReadLine());
Câu 1.7: static void Bai7()
{ Console.Write("Nhap thang: ");
Console.WriteLine("\t\t\t\t\t\t\tBai7"); int month = int.Parse(Console.ReadLine());
int x;
bool isValidInput; Console.Write("Nhap nam: ");
do int year = int.Parse(Console.ReadLine());
{ bool isValid = true;
try
{ switch (month)
Console.Write("Nhap Vao Mot So Nguyen: "); {
x = int.Parse(Console.ReadLine()); case 1:
case 3:
if (x % 2 == 0) case 5:
{ case 7:
Console.WriteLine("So chan"); case 8:
} case 10:
else case 12:
{ if (day < 1 || day > 31) isValid = false;
Console.WriteLine("So le"); break;
}
isValidInput = true; case 4:
} case 6:
catch (FormatException) case 9:
{ case 11:
Console.WriteLine("Loi: Vui Long Nhap Mot So Nguyen Hop Le"); if (day < 1 || day > 30) isValid = false;
isValidInput = false; break;
}
} while (!isValidInput); case 2:
bool isLeapYear = (year % 400 == 0) || (year % 100 != 0 && year % 4 == 0);
} if (day < 1 || day > (isLeapYear ? 29 : 28)) isValid = false;
Câu 1.8: static void Bai8() break;
{
double a; default:
Console.WriteLine("\t\t\t\t\t\t\tBai8"); isValid = false;
Console.WriteLine("Chuong Trinh Tinh Luong Cua Nhan Vien TNCT"); break;
Console.Write("Nhap So Thang TNCT: "); }
double canban = 1350000;
double hesoluong; if (!isValid || year < 1)
a = double.Parse(Console.ReadLine()); {
if (a < 12) Console.WriteLine("Ngay thang nam khong hop le!");
{ return;
Console.WriteLine($"So thang TNCT: {a} < 12"); }
hesoluong = 2.34; DateTime currentDate = new DateTime(year, month, day);
} DateTime yesterday = currentDate.AddDays(-1);
else if (a >= 12 && a < 36) DateTime tomorrow = currentDate.AddDays(1);
{ Console.WriteLine();
Console.WriteLine($"So thang TNCT: 12<={a}<36"); Console.WriteLine($"Ngay hom qua: {yesterday:dd/MM/yyyy}");
hesoluong = 2.67; Console.WriteLine($"Ngay hom nay: {currentDate:dd/MM/yyyy}");
} Console.WriteLine($"Ngay mai: {tomorrow:dd/MM/yyyy}");
else if (a >= 36 && a < 60) }
{ Câu 2.8: static void Bai8()
Console.WriteLine($"So thang TNCT: 36<={a}<60"); {
hesoluong = 3.0; while (true)
} {
else Console.WriteLine("CHUONG TRINH GIAI PHUONG TRINH");
{ Console.WriteLine("1. Phuong trinh bac 1 (ax + b = 0)");
Console.WriteLine($"So thang TNCT: {a}>=60"); Console.WriteLine("2. Phuong trinh bac 2 (ax^2 + bx + c = 0)");
hesoluong = 3.33; Console.WriteLine("3. Phuong trinh bac 3 (ax^3 + bx^2 + cx + d = 0)");
} Console.WriteLine("4. Thoat");
double luong = hesoluong * canban; Console.Write("Chon chuc nang (1-4): ");
Console.WriteLine($"He so luong: {hesoluong}");
Console.WriteLine($"Luong cua nhan vien: {luong.ToString("N0")} VND"); int choice;
Console.ReadKey(); if (!int.TryParse(Console.ReadLine(), out choice))
} {
Câu 1.9: static void Bai9() Console.WriteLine("Vui long nhap so!");
{ continue;
Console.WriteLine("\t\t\t\t\t\t\tBai9"); }
Console.WriteLine("\t\t\t\t\t\tChuong Trinh Tinh Tien Dien");
Console.Write($"Nhap so KW tieu thu: "); switch (choice)
double a = double.Parse(Console.ReadLine()); {
case 1:
double dongia; GiaiPTBac1();
if (a <= 100) break;
{ case 2:
Console.WriteLine($"donggia: {dongia = 2000}Dong"); GiaiPTBac2();
} break;
else if (a >= 101 && a <= 200) case 3:
{ GiaiPTBac3();
Console.WriteLine($"donggia: {dongia = 2500}Dong"); break;
} case 4:
else if (a >= 201 && a <= 300) Console.WriteLine("Ket thuc chuong trinh!");
{ return;
Console.WriteLine($"donggia: {dongia = 3000}Dong"); default:
} Console.WriteLine("Lua chon khong hop le!");
else break;
{ }
Console.WriteLine($"donggia: {dongia = 5000}Dong"); Console.WriteLine();
} }
double z = a * dongia; }
Console.WriteLine($"Tien dien: {z.ToString("N0")} VND");
Console.ReadKey(); static void GiaiPTBac1()
} {
Câu 1.10: static void Bai10() Console.Write("Nhap a: ");
{ double a = double.Parse(Console.ReadLine());
Console.WriteLine("\t\t\t\t\t\t\tBai10"); Console.Write("Nhap b: ");
Console.WriteLine("\t\t\t\t\t\tChuong Trinh Tinh Tien Karaoke"); double b = double.Parse(Console.ReadLine());
if (found)
{
Console.WriteLine($"Số dương lẻ nhỏ nhất trong mảng là: {min}");
}
else
{
Console.WriteLine("Không tìm thấy số dương lẻ trong mảng.");
}
}
if (found)
{
Console.WriteLine($"Số dương chẵn lớn nhất trong mảng là: {max}");