Console.Write("Enter the price: "); double price = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter your province: "); string province = Convert.ToString(Console.ReadLine().ToUpper()); includingTax(price, province); Console.Write("Enter the celsisus: "); double celsius = Convert.ToDouble(Console.ReadLine()); celsiusToFahrenheit(celsius); Console.Write("Enter the celsisus: "); double celsius2 = Convert.ToDouble(Console.ReadLine()); celsiusToFahrenheit(celsius2); Console.Write("Enter the starting value: "); double startingValue = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter the step size: "); double stepSize = Convert.ToDouble(Console.ReadLine()); displaySineTable(stepSize, startingValue); Console.Write("Enter your height by using centimeter: "); double cm = Convert.ToDouble(Console.ReadLine()); convertHeight(cm); } #region Q_1 /*Write a method called DisplayHorizontalStars(int numberOfStars). *This method will output the number of stars horizontally specified by its argument. *Call the DisplayHorizontalStars() method three times from your program Main() method, supplying 0, 5 and 10 number of stars*/ static void DisplayHorizontalStars(int numberOfStars) { Console.WriteLine("{0} Lines", numberOfStars); for (; numberOfStars > 0; numberOfStars--) { Console.Write("**********\n"); } } #endregion #region Q_4 /*4. Write a method that takes two arguments: * a cost price and a two letter province code. * It will calculate and display the selling price. * (If province is Ontario a tax of 13% is added to the price, * if the province is Quebec a tax of 17% is added to the cost price. * There is no tax for the rest of the provinces and territories). * In your main, call this method enough times to fully test it*/ static void includingTax(double price, string province) { double rate = 0; if (province == "ON") rate = 0.13; else if (province == "QB") rate = 0.17; else rate = 0; double totalPrice = (1 + rate) * price; Console.WriteLine("Tax + Price = {0:c2}", totalPrice); } #endregion #region Q_5 /*5. Write a method that takes a single argument of type double. * The will display a Celsius to Fahrenheit conversion table. * The starting temperature is indicated by the argument * and it will display 10 lines in increments of 1. * In your main call this method two times.*/ static void celsiusToFahrenheit(double celsius) { Console.WriteLine(" Celsius Fahrenheit"); for (int i = 0; i < 10; i++) { Console.WriteLine("{0:f2} {1:f2}", celsius, 1.8 * celsius + 32); celsius++; } } #endregion #region Q_7 /*7. Modify the DisplaySineTable in the previous section to accept the start value, * the step size and number of rows as argument to the method.*/ static void displaySineTable(double stepSize, double startingValue) { for (int i = 0; i < 10; i++) { double sinValue = Math.Sin(startingValue); Console.WriteLine("{0,10:f2}{1,10:f4}", startingValue, sinValue); startingValue += stepSize; } } #endregion #region Q_8 /*8. Write a method that converts a person’s height from centimeter to meters * and centimeters and display the result on the console. * In your main method, you should prompt the user for his height in cm * and then call the method with this value.*/ static void convertHeight(double cm) { Console.WriteLine("{0}cm = {1:f0}m {2:f2}cm", cm, Math.Truncate(cm / 100), cm % 100); } #endregion }