Exemple #1
0
        public static void ShowPrice()
        {
            // Getting the input and calling the calculate age method
            uint input = Util.AskForInt("Input the age of the person:");

            CinemaTickets.CalculatePriceByAge(input);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            do
            {
                // Starting the menu
                Console.WriteLine();
                Console.WriteLine("***************************************************************");
                Console.WriteLine("Welcome to the main menu. Please navigate by choosing a number!");
                Console.WriteLine("1. Check the price of a ticket for 1 person");
                Console.WriteLine("2. Check the price of tickets for a group");
                Console.WriteLine("3. Make your text repeat itself 10 times");
                Console.WriteLine("4. Write a sentence and the system will print out your third word");
                Console.WriteLine("0. Close the program");
                Console.WriteLine("***************************************************************");

                // Asking for input
                string selection = Util.AskForSelection("Your selection: ");

                // Terminating the program if 0 is chosen
                if (selection == "0")
                {
                    break;
                }

                // Switch calling different classes according to the input
                switch (selection)
                {
                case "1":
                    Console.WriteLine();
                    CinemaTickets.ShowPrice();
                    break;

                case "2":
                    Console.WriteLine();
                    CinemaTicketsGroup.ShowPrice();
                    break;

                case "3":
                    Console.WriteLine();
                    StringRepeater.PrintString();
                    break;

                case "4":
                    Console.WriteLine();
                    ThirdWordChooser.SplitAndPrint();
                    break;

                default:
                    Console.WriteLine("This is not a valid selection. Please try again!");
                    Console.WriteLine("------------------------------------------------");
                    break;
                }
            }while (true);
        }
Exemple #3
0
        public static void ShowPrice()
        {
            // Why it complains for total price but not for ticketPrice??
            // Defining variables to be used
            uint movieGoers = Util.AskForInt("How many persons are going to the movies?");
            uint totalPrice = 0;
            uint ticketPrice;

            // Looping through the number of movie goers
            for (int i = 0; i < movieGoers; i++)
            {
                Console.WriteLine();
                uint input = Util.AskForInt($"Input the age of person number {i+1}:");
                ticketPrice = CinemaTickets.CalculatePriceByAge(input);
                totalPrice += ticketPrice;
            }

            // Final output of the total price
            Console.WriteLine();
            Console.WriteLine($"The total price of the tickets is: {totalPrice}kr");
        }