Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that can be used to determine the tip amount that should be adde

ID: 3665636 • Letter: W

Question

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 restaurant charge, before taxes. Produce output showing the calculated values including the total amount due for both 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. Be sure to provide labels for values and number align them

Explanation / Answer

Code:

#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:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote