Esempio n. 1
0
        public void MainMenu(int nrChoose)
        {
            switch (nrChoose)
            {
            case 1:
                Console.Clear();
                BC bc = new BC();
                bc.CalMain();
                break;

            case 2:
                Console.Clear();
                BMI bmi = new BMI();
                bmi.BMIMain();
                break;

            case 3:
                Console.Clear();
                DC dc = new DC();
                dc.DCMain();
                break;

            case 4:
                Console.Clear();
                CalculatorMeWe calculatorMeWe = new CalculatorMeWe();
                calculatorMeWe.MainCalc();
                break;

            case 5:
                System.Diagnostics.Process.GetCurrentProcess().Kill();
                break;

            default:
                Console.Clear();
                bool falsee = false;
                Menu menu   = new Menu();
                menu.MainCalc(falsee);
                break;
            }
        }
Esempio n. 2
0
        public static void Main()
        {
            //Creating the objects of the classes
            Program c = new Program();
            BMI     b = new BMI();

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("==============\n  Calculator \n============== ");
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Please select what calculator you want to use" + "\n1. Normal Calculator\n2. BMI Calculator");
            string yas = Console.ReadLine();

            if (yas == "1")
            {
                c.switchStatement();
            }
            else if (yas == "2")
            {
                b.Bmi();
            }
            Console.WriteLine(c.used);
        }
Esempio n. 3
0
        public void BMIMain()
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("BMI Calculator");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Enter weight:");
            String weightS   = Console.ReadLine();
            bool   AllDigits = weightS.Any() && weightS.All(char.IsDigit);

            while (AllDigits == false)
            {
                Console.WriteLine("Wrong weight");
                weightS   = Console.ReadLine();
                AllDigits = weightS.Any() && weightS.All(char.IsDigit);
            }
            weight = double.Parse(weightS);
            Console.WriteLine("Enter height:");
            String heightS = Console.ReadLine();

            AllDigits = heightS.Any() && heightS.All(char.IsDigit);
            while (AllDigits == false)
            {
                Console.WriteLine("Wrong weight");
                heightS   = Console.ReadLine();
                AllDigits = heightS.Any() && heightS.All(char.IsDigit);
            }
            height = double.Parse(heightS);

            bmi = weight / (height * height) * 10000;
            Console.WriteLine("Your BMI: " + "{0:N2}", bmi);
            if (bmi <= 18.5)
            {
                Console.WriteLine("You are too skinny. Correct BMI is 18.6 - 24.99. Eat more and healthily");
            }
            else
            {
                if (bmi == 18.51 && bmi <= 25)
                {
                    Console.WriteLine("Your weight is correct(18.6 - 24.99");
                }
                else
                {
                    if (bmi >= 25)
                    {
                        Console.WriteLine("Your weight is too big. Correct BMI is 18.6 - 24.99. Eat less and healthily");
                    }
                }
            }
            Console.WriteLine("1. Reset calculator");
            Console.WriteLine("2. Return to Main Menu");
            String ChoseRBS;

            ChoseRBS  = Console.ReadLine();
            AllDigits = ChoseRBS.Any() && ChoseRBS.All(char.IsDigit);
            while (AllDigits == false)
            {
                Console.WriteLine("Wrong choice");
                ChoseRBS  = Console.ReadLine();
                AllDigits = ChoseRBS.Any() && ChoseRBS.All(char.IsDigit);
            }
            int  ChoseRB = int.Parse(ChoseRBS);
            bool isTrue  = false;

            while (isTrue == false)
            {
                switch (ChoseRB)
                {
                case 1:
                    isTrue = true;
                    Console.Clear();
                    BMI bmi = new BMI();
                    bmi.BMIMain();

                    break;

                case 2:
                    isTrue = true;
                    Console.Clear();
                    Menu menu = new Menu();
                    menu.MainCalc(true);
                    break;

                default:
                    isTrue = false;
                    Console.Clear();
                    Console.Write("Wrong choice");
                    break;
                }
            }
        }