Answer to Question #266356 in C# for Emily

Question #266356

Write a program that can be used to determine the tip amount that should be added to a restaurant charge. Allow the user to input the total, before taxes and the tip percentage (15% or 201%). Produce output showing the calculated values including the total amount due for both the 15% and the 201% tips. Tax of 9% should be added to the bill before the tip is determined. Display subtotal showing the amount owed prior to applying the tip, show each tip amount and the totals with each tip amount. Be sure to provide labels for values and the totals with each tip amount. Write appropriate methods for your solution.


1
Expert's answer
2021-11-15T12:36:07-0500
using System;
using System.Collections.Generic;


namespace App
{
    class Program
    {


        static double calculateTip15(double billAmount)
        {
            return billAmount*0.15;
        }
        static double calculateTip201(double billAmount)
        {
            return billAmount * 2.01;
        }


        static double calculateTax(double billAmount)
        {
            return billAmount * 0.09;
        }


        static void Main(string[] args)
        {
            Console.Write("Enter the bill amount: ");
            double billAmount = double.Parse(Console.ReadLine());
            double tax = calculateTax(billAmount);
            double subtotal = billAmount + tax;
            double tip15 = calculateTip15(subtotal);
            double tip201 = calculateTip201(subtotal);
            double totalAmountDue = subtotal + tip15 + tip201;


            Console.WriteLine("\nThe subtotal (the amount owed prior to applying the tip): {0}", subtotal.ToString("C"));
            Console.WriteLine("Tax of 9%: {0}", tax);
            Console.WriteLine("The total amount due for the 15% tips: {0}", tip15.ToString("C"));
            Console.WriteLine("The total amount due for the 201% tips: {0}",tip201.ToString("C"));
            Console.WriteLine("The total amount due: {0}", totalAmountDue.ToString("C"));


            
            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS