Need help with one of the exercises in the book.Write a program in c# that can b
ID: 3912089 • 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
#include <stdio.h>
float calculate_tax(float amount)
{
return amount*0.09;
}
float calculate_tip(float amount, int percent)
{
return amount*percent/100;
}
int main()
{
float restarent_charge=0,tax,tip,total_before_tip,total;
printf("Enter the restaurent charges before Tax ");
scanf("%f",&restarent_charge);
tax = calculate_tax(restarent_charge);
printf("********************************************** ");
printf("*************your bill *************** ");
printf("********************************************** ");
printf("Restaurent chrges ..... %.2f ",restarent_charge);
printf("Tax ................... %.2f ",tax);
printf("---------------------------------------------- ");
total_before_tip = restarent_charge + tax;
printf("total before tip....... %.2f ",total_before_tip);
tip=calculate_tip(total_before_tip,15);
printf("amount after 15% tip.... %.2f ",total_before_tip+tip);
tip=calculate_tip(total_before_tip,20);
printf("amount after 20% tip.... %.2f ",total_before_tip+tip);
return 0;
}
Output:
Enter the restaurent charges before Tax
**********************************************
************* your bill ***************
**********************************************
Restaurent chrges ..... 143.00
Tax ................... 12.87
----------------------------------------------
total before tip....... 155.87
amount after 15 31p.... 179.25
amount after 20 31p.... 187.04
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.