/* * Next create method "Input BMI". Within a new insance of object "BMI" called "one" is created. Then * the user is promted for input. Depending on the user input their hight and weight and either method * "CalculateIBMI" or "CalculateMBMI" is called. */ public static void InputBMI() { BMI one = new BMI(); //new object "one" created WriteLine("Enter 1 for Imperial or 2 for Metric"); // promted for user input string choice = ReadLine(); //variable "choice" is declared and defined if (choice == "1") //set parameters for what to do if the user inputs "1" as choice. { WriteLine("Enter you weight in pounds:"); one.weight = ReadLine(); WriteLine("Enter your height in inches:"); one.height = ReadLine(); double.TryParse(one.weight, out one.w);//converting user input from string to double for calculations double.TryParse(one.height, out one.h); one.CalculateIBMI(); } else if (choice == "2")//set parameters for what to do if the user inputs "2" as choice. { WriteLine("Enter you weight in kilos:"); one.weight = ReadLine(); WriteLine("Enter your height in meters:"); one.height = ReadLine(); double.TryParse(one.weight, out one.w); double.TryParse(one.height, out one.h); one.CalculateMBMI(); } else//set parameters for what to do if the user inputs an unlisted choice. { WriteLine("You don't listen, you must be American lol!\nEnter you weight in pounds:"); one.weight = ReadLine(); WriteLine("Enter your height in inches:"); one.height = ReadLine(); double.TryParse(one.weight, out one.w); double.TryParse(one.height, out one.h); WriteLine("Your BMI:"); one.CalculateIBMI(); } }
static void Main(string[] args) { RoNumDis.Display(); //Exercise 1 BMI.InputBMI(); //Exercise 3 Area.AreaDisplay(); //Exercise 6 }