/******************************************************/ /* Introduction to Programming */ /* By Dr. ANTF */ /* www.antf.net */ /* Copyright 2015 */ /* */ /* C# 405 - Problem 4: Grass Cutting (b) */ /******************************************************/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DOS { class Program { static int Area(int width, int height) { return width * height; } static void DisplayTime(int min) { if (min < 60) Console.Write("{0} min", min); else if(min < 1440) // less than one day { Console.Write("{0} hr ", min / 60); Console.Write("{0} min", min % 60); } else //more than one day { Console.Write("{0} days ", min / 1440); Console.Write("{0} hrs ", (min % 1440) / 60); Console.Write("{0} min", (min % 1440) % 60); } } static void Main(string[] args) { int land_w, land_h, buld1_w, buld1_h, buld2_w, buld2_h, area; Console.Write("Please enter Land width: "); land_w = int.Parse(Console.ReadLine()); Console.Write("Please enter Land height: "); land_h = int.Parse(Console.ReadLine()); Console.Write("Please enter Building 1 width: "); buld1_w = int.Parse(Console.ReadLine()); Console.Write("Please enter Building 1 height: "); buld1_h = int.Parse(Console.ReadLine()); Console.Write("Please enter Building 2 width: "); buld2_w = int.Parse(Console.ReadLine()); Console.Write("Please enter Building 2 width: "); buld2_h = int.Parse(Console.ReadLine()); area = Area(land_w, land_h) - Area(buld1_w, buld1_h) - Area(buld2_w, buld2_h); Console.Write("\n\nTotal time needed to cut the grass is: "); DisplayTime(area * 5); Console.ReadKey(); } } }