Example #1
0
        public static void Start()
        {
            // Prompt user for first inputs
            Console.Write("\r\nGas Bot wants to know: \r\n" +
                          "How many trips do you wish to take? ");

            // Call Validate method and store in variable for later use
            double trips = Validate.Input(Console.ReadLine());

            // Declare variable that call the TotalMiles method, taking the GetMilesMethod, that takes trips as a parameter
            double milesInTotal = GasBot.TotalMiles(GasBot.TripMiles(trips));

            // Prompt user for gathering mpg value
            Console.WriteLine("\r\nGas Bot wants to know:\r\nHow many miles per gallon of gas does your vehicle get? ");

            // Validate and store input by calling the Validate method
            double milesPerGal = Validate.Input(Console.ReadLine());

            //Prompt user for cost of 1 gal of gas
            Console.Write("\r\nGas Bot wants to know:\r\nHow much is gas right now? Use 00.00 format please. ");

            // Validate and store input by calling the Validate method
            decimal pricePerGal = (decimal)Validate.Input(Console.ReadLine());

            // Store the total cost of gas from all trips by calling the CostOfGas method, taking in all prior input as argumants
            decimal totalCost = GasBot.CostOfGas(milesInTotal, milesPerGal, pricePerGal);

            // Inform user of total cost of gas
            Console.WriteLine("\r\nThe cost of driving {0} miles is {1:C}.", milesInTotal, totalCost);

            Console.WriteLine("\r\nThank you for using Gas Bot!");
        }