#SEC_061
Explore tagged Tumblr posts
thevz · 10 years ago
Text
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace part_I { class Program { static void Main(string[] args) { DisplayPersonalInfo(); CalculateAreaOfCircle(); CalculateSaleCommission(); //ShowMenu(); } #region Q1. /*1. Write a method called DisplayPersonalInfo() to display your name, school, * program and your favorite course. * Call the DisplayPersonalInfo() method from your program Main() method*/ static void DisplayPersonalInfo() { Console.Write("Name: Hansung Kim\n"); Console.Write("School: Centennial College\n"); Console.Write("Program: Gaming\n"); Console.Write("Favorite Course: COMP100\n\n"); } #endregion #region Q3. /*3. Write a method call CalculateAreaOfCircle(), * that prompts the user for the radius of a circle and then calculate and display the area. * [A = πr2] * Call the CalculateAreaOfCircle() method from the same Main() method as in question 1.*/ static void CalculateAreaOfCircle() { Console.Write("Enter the radius of a circle: "); int r = Convert.ToInt32(Console.ReadLine()); double area = Math.PI * r * 2; Console.WriteLine("{0:f2}\n", area); } #endregion #region Q5. /*5. Write a method call CalculateSaleCommission(), * that prompts the user for his sales figure, and then calculate and display his commission. * (commission = ¼ % of sales over 1000. * If sales is below $1000.00 there is no commission) * Call the CalculateSaleCommission() method from the same Main() method as in question 1.*/ static void CalculateSaleCommission() { Console.Write("Enter the cost of sales: "); double cost = Convert.ToDouble(Console.ReadLine()); double commission; if (cost > 1000) commission = cost * 1 / 4; else commission = 0; Console.Write("Your commision: {0:c2}\n", commission); } #endregion #region Q7. //지저분해서 지움.. #endregion #region Q8. /*8. Add another method called ShowMenu() to your project. * This method will call the method in question 7 continuously until the user presses 0. * (You will have to invoke the method in a loop body, read in the user input as well as check the input)*/ static void ShowMenu() { for (;;) { Console.Write("Choose the number: "); int call = Convert.ToInt32(Console.ReadLine()); switch (call) { case 1 : DisplayMenu(); case 2: DisplayMenu(); case 3: DisplayMenu(); break; } } } #endregion } }
0 notes