Need help with one of the exercises in the book.Write a program in c# that can b
ID: 3912695 • Letter: N
Question
Need help with one of the exercises in the book.Write a program in c# that can be used to determine the tip amount that should be added to a restaurant charge. Allow the user to input the restaurant charge, before taxes. Produce output showing the calculated values including the total amount due for 5%,10%, 15% and the 20% tips. Tax of 9% should be added to the bill before the tip is determined. Write appropriate methods for your solution. Display subtotal showing the amount owed prior to applying a tip. Show each tip amount and the totals with each tip amount. Display instructions and use modular solution.
Explanation / Answer
Hope You Like It !!
using System;
class Program
{
static void Main() //main Function
{
string userInput;
double basic;double taxrate=9; //taxrate is fixed at 9%
Console.Write("Enter Resturant Basic Charge value: "); //print messege to user to enter the basic bill amount
userInput = Console.ReadLine(); //Read the string Input
/* Converts to integer type */
basic = Convert.ToDouble(userInput); //convert string input to double
billcal(basic,taxrate); //call the billcal function to get the desired result
}
static void billcal(double basic,double taxrate){ //start of billcall function
double withtax=basic+(basic*taxrate*.01); //calculate bill with tax
//double amountdue;
Console.Write("Amount due before tip is "+withtax); //Total amount with tax and no Tip.
Console.Write(" Amount due for Tip=5% is "+withtax*1.05); //calculated total amouunt due including tax of 9% and tip of 5%
Console.Write(" Amount due for Tip=10% is "+withtax*1.10); //calculated total amouunt due including tax of 9% and tip of 10%
Console.Write(" Amount due for Tip=15% is "+withtax*1.15); //calculated total amouunt due including tax of 9% and tip of 15%
Console.Write(" Amount due for Tip=20% is "+withtax*1.20); //calculated total amouunt due including tax of 9% and tip of 20%
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.