

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This c# console application demonstrates basic geometry calculations, including finding the circumference and area of a circle, calculating the total income and deductions for an employee based on the number of working days and dependents, computing the total score and average score of three exam subjects, determining the hypotenuse and perimeter of a right triangle given the lengths of the other two sides, and finding the radius of a circle given its perimeter. The program consists of five separate methods, each addressing a specific geometric problem. This document could be useful for students studying c# programming, data types, console input/output, and basic mathematical operations in the context of geometry and finance-related calculations.
Typology: Exercises
1 / 2
This page cannot be seen from the preview
Don't miss anything!


using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp { internal class Program { static void Main(string[] args) { Cau_1(); Cau_2(); Cau_3(); Cau_4(); Cau_5(); } static void Cau_1() { Console.Write("Ban kinh hinh tron la: "); float r = float.Parse(Console.ReadLine()); float CV = (float)(2rMath.PI); float S = (float)(Math.PI * r * r); Console.WriteLine("Chu vi hinh tron la {0}\nDien tich hinh tron la {1}",CV,S); } static void Cau_2() { Console.Write("So ngay di lam: "); int ngay = int.Parse(Console.ReadLine()); Console.Write("So con cai: "); int con=int.Parse(Console.ReadLine()); int TLNC = 100000 * ngay; int PC = 150000 * con; int BHXH = TLNC * 15/100 ; int TL = TLNC + PC - BHXH; Console.WriteLine("Tien luong ngay cong la {0} VND\nTien phu cap la {1} VND", TLNC, PC); Console.WriteLine("Dong Bao hiem xa hoi la {0} VND\nTien lanh {1} VND", BHXH, TL); } static void Cau_3() { Console.Write(" Diem thi mon toan : "); float Toan = float.Parse(Console.ReadLine()); Console.Write(" Diem thi mon ly : "); float Ly = float.Parse(Console.ReadLine()); Console.Write(" Diem thi mon hoa : "); float Hoa = float.Parse(Console.ReadLine()); float TC = (float)(Toan + Ly + Hoa); float TB = (float)(TC / 3);
Console.WriteLine("Diem tong cong la {0}\nDiem trung binh la {1}", TC,TB); } static void Cau_4() { Console.WriteLine(" Canh hinh vuong 1 la: "); float a = float.Parse(Console.ReadLine()); Console.WriteLine(" Canh hinh vuong 2 la: "); float b = float.Parse(Console.ReadLine()); float c = (float)(Math.Sqrt(a * a + b * b)); float CV = (float)(a + b + c); float S = (float)(a*b/2); Console.WriteLine("Hinh vuong co canh huyen la: {0}\nChu vi la: {1}\nDien tich la: {2} ",c,CV,S ); } static void Cau_5() { Console.WriteLine("Canh cua hinh vuong la "); float a = float.Parse(Console.ReadLine()); float CVHV = a * 4; Console.WriteLine("Chu vi hinh vuong la :" + CVHV); float R = (float)(CVHV / (2 * Math.PI)); Console.WriteLine("Ban kinh la :" + R); } } }