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!");
        }
Example #2
0
        static void Main(string[] args)
        {
            /* Christopher Westman
             * 12/14/2017
             * Week 4, FINAL PROJECT!!!
             */
            // Greet user and explain program
            Console.WriteLine("Welcome to GAS BOT! This app will calculate the cost of your gas for multiple trips!");

            GasBot.Start();

            /* Use data for testing
             * Enter a negative number, blank, or letters on any prompt, reprompted for valid entry
             * Test #1
             * Enter 3 for trips taken
             * Enter 200 for trip #1
             * Enter 100 for trip #2
             * Enter 30 for trip #3
             * Enter 30 for number of miles per gallon of gas
             * Enter 2.20 for price of gas
             * Output: "The cost of driving 330 miles is $24.20."
             * Test #2
             * Enter 3 for trips taken
             * Enter 10 for trip #1
             * Enter 15 for trip #2
             * Enter 25 for trip #3
             * Enter 25 for number of miles per gallon of gas
             * Enter 1 for price of gas
             * Output: "The cost of driving 50 miles is $2.00."
             * Test #3
             * Enter 20 for trips taken
             * Enter 1 for trip #1
             * Enter 1 for each trip until finish with trip input
             * Enter 2 for number of miles per gallon of gas
             * Enter 4.00 for price of gas
             * Output: "The cost of driving 20 miles is $40.00."
             */
        }