Đây là code của em
Mã:
public class time
{
public int gio { get; set; }
public int phut { get; set; }
public int giay { get; set; }
public void print12()
{
Console.WriteLine("Dạng 12 giờgày: ");
if (this.gio >= 12)
{
Console.WriteLine("{0}:{1}:{2} PM", this.gio - 12, this.phut, this.giay);
}
else
{
Console.WriteLine("{0}:{1}:{2} AM", this.gio, this.phut, this.giay);
Console.ReadKey();
}
}
public void print24()
{
Console.WriteLine("Dạng 24 giờgày: ");
Console.WriteLine("{0}:{1}:{2}", this.gio, this.phut, this.giay);
}
public void Tanggiay(int s)
{
this.giay = s + 1;
}
public void Tangphut(int p)
{
if (this.giay == 60)
{
this.phut = p + 1;
this.giay = 0;
}
}
public void Tanggio(int h)
{
if (this.phut == 60)
{
this.gio = h + 1;
this.phut = 0;
if (this.gio == 24)
{
this.gio = 0;
}
}
}
class program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.UTF8;
time TG = new time();
Console.Write("Nhập giờ: ");
TG.gio = int.Parse(Console.ReadLine());
Console.Write("Nhập phút: ");
TG.phut = int.Parse(Console.ReadLine());
Console.Write("Nhập giây: ");
TG.giay = int.Parse(Console.ReadLine());
TG.print12();
TG.print24();
Console.ReadKey();
for (int i = 1; i <= 5; i++)
{
TG.Tanggiay(TG.giay);
TG.Tangphut(TG.phut);
TG.Tanggio(TG.gio);
Console.WriteLine("Thời gian sau khi tăng {0} giây là: ", i);
TG.print12();
TG.print24();
}
}
}
}
}
View more random threads:
Vòng tay phong thủy là một vật phẩm mang lại sự may mắn trong tài lộc, tình duyên, sự nghiệp,.. Là một vật phẩm không xa lạ gì với chúng ta, vòng tay phong thủy có nhiều màu, đa dạng và mỗi màu sắc...
Ý nghĩa và cách phân loại vòng tay...