Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Bài Tập Programmin 3

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

BÀI TẬP PROGRAMMING

1. Integer and real numbers


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Homework_4_02
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Nhap so nguyen a: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Nhap so nguyen b: ");
int b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Nhap so nguyen c: ");
int c = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Nhap so nguyen d: ");
int d = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\nTong cua hai so a+b = " + (a + b));
Console.WriteLine("\nthuong cua hai so {a+b} / c = " + (a + b) / c);
Console.WriteLine("\nTich cua hai so ({a+b} /c) * d = " + ((a + b) / c) * d);
Console.ReadLine();
}
}
}

2. Circle Area
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Homework4_02_2_
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Nhap vao ban kinh r: ");
double r = double.Parse(Console.ReadLine());
Console.WriteLine("Dien tich duong tron la: ");
Console.WriteLine("{0:F12}", Math.PI * r * r);
Console.ReadLine();
}
}
}
3. Exact sum of real numbers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Homework4_02_3_
{
internal class Program
{
static void Main(string[] args)
{
int count = int.Parse(Console.ReadLine());
decimal sum = 0;
for (int i = 0; i < count; i++)
{
decimal number = decimal.Parse(Console.ReadLine());
sum += number;
}
Console.WriteLine(sum);
Console.ReadLine();
}
}
}
4. Centuries to minutes

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Homework4_02_
{
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Centuries = ");
int centuries = int.Parse(Console.ReadLine());
int years = centuries * 100;
int days = (int)(years * 365.2422);
int hours = days * 24;
int minutes = hours * 60;
Console.WriteLine("{0} centuries = {1} years = {2} days = {3} hours ={ 4} minutes",
centuries, years, days, hours, minutes);
Console.ReadLine();
}
}
}
5. Triples of latin letters

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Homework4_02_6_
{
internal class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
for (char a = 'a'; a < 'a' + n; a++)
{
for (char b = 'a'; b < 'a' + n; b++)
{
for (char c = 'a'; c < 'a' + n; c++)
{
Console.WriteLine($"{a}{b}{c}");
Console.ReadLine();
}
}
}
}
}
}
6. Rafactor volume of pyramid
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace homework4_02_7_
{
internal class Program
{
static void Main(string[] args)
{
double dul, sh, V = 0;
Console.Write("Length: ");
dul = double.Parse(Console.ReadLine());
Console.Write("Width: ");
sh = double.Parse(Console.ReadLine());
Console.Write("Heigth: ");
V = double.Parse(Console.ReadLine());
V = (dul + sh + V) / 3;
Console.WriteLine("Pyramid Volume: {0:F2}", V);
Console.ReadLine();
}
}
}

You might also like