Untitled
DragonNZ
csharp
3 years ago
5.2 kB
7
Indexable
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { mainMenu(); Console.WriteLine("Thank you for using the City Gym App, Goobye!"); } static void mainMenu() { string appName = "City Gym App"; //Aoolication name string appVersion = "1.0"; //Application version bool quit = false; //when true will quit application while (!quit) { Console.WriteLine("Welcome to " + appName + appVersion); Console.WriteLine("1. BMI Calculator"); Console.WriteLine("2. Membership Rates"); Console.WriteLine("Please enter the number of your menu selection (0 to exit)"); string menuSelection = Console.ReadLine(); switch (menuSelection) { case "0": quit = true; break; case "1": quit = BMI_Calculator(); break; /*if return true, start menu again? */ case "2": quit = membershipRates(); break; default: Console.WriteLine("Please enter a valid number"); continue; } } } static bool BMI_Calculator() //BMI Calculator funciton { float userWeight; float userHeight; bool running = true; while (running) { Console.WriteLine("Welcome to the BMI Calculator"); Console.WriteLine("To return to main menu at any time, type 0"); Console.WriteLine("Please enter your weight in kg"); userWeight = float.Parse(Console.ReadLine()); //Get users weight if (userWeight != 0) //check if quitting application or entering weight { Console.WriteLine("Please enter your height in metres"); userHeight = float.Parse(Console.ReadLine()); //get users height if (userHeight != 0) //check if quitting application or entering height { float BMI = (userWeight / (userHeight * userHeight)); //BMI Calculation //BMI Results if (BMI < 18.5) { Console.WriteLine("Your BMI is " + BMI + "Underweight"); } else if (BMI >= 18.5 && BMI < 24.9) { Console.WriteLine("Your BMI is " + BMI + "Normal"); } else if (BMI > 25 && BMI < 30) { Console.WriteLine("Your BMI is " + BMI + "Overweight"); } else if (BMI >= 30) { Console.WriteLine("Your BMI is " + BMI + "Obese"); } } else { return false; } } else { return false; } } return false; } static bool membershipRates() { bool running = true; bool quit = false; while (running) { Console.WriteLine("To see membership rates, please enter the number of the membership"); Console.WriteLine("1. Basic"); Console.WriteLine("2. Regular"); Console.WriteLine("3. Premium"); Console.WriteLine("Please enter your selection (0 to return to Main Menu, 9 to Quit)"); string rateSelection = Console.ReadLine(); switch (rateSelection) { case "0": running = false; break; case "9": running = false; quit = true; break; case "1": Console.WriteLine("Basic membership is $10 weekly or $40 monthly"); break; case "2": Console.WriteLine("Regular membership is $15 weekly or $60 monthly"); break; case "3": Console.WriteLine("Premium membership is $20 weekly or $80 monthly"); break; } } return quit; } } }
Editor is loading...