Question

Bill and Tip Calculator Write a C program to generate a receipt for a restaurant. Your...

Bill and Tip Calculator

Write a C program to generate a receipt for a restaurant.

Your application should allow the user to enter the bill amount and allow them to decide if they would like to leave a 15 percent tip or not.

▪ Do not allow the user to enter a negative value for the bill.

▪ Display the bill amount, tax amount, tip amount, and total amount.

▪ To calculate the tip, multiply the bill amount by 0.15. To calculate the tax, multiply the bill amount by 0.0825.

▪ To calculate the total, add the tip, tax, and bill.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program screenshots:

Sample output:

Code to copy:

// Include the required header files.

#include <stdio.h>

// Define the main() function.

int main()

{

    // Declare the required variables.

    float bill_amount = 0;

    float tip_amount = 0, tax_amount, total;

    char choice;

    // Prompt the user to enter the bill amount.

    printf("Enter the bill amount: ");

    scanf("%f", &bill_amount);

    // Prompt the user to enter the amount

    // again if the amount is negative.

    while (bill_amount < 0)

    {

        printf("Bill amount cannot be negative!\n");

        printf("Enter the bill amount: ");

        scanf("%f", &bill_amount);

    }

    scanf("%c", &choice);

    // Compute the tip amount and ask the

    // user if they want to pay the tip

    // amount or not.

    tip_amount = bill_amount * 0.15;

    printf("Tip amount = %f\n", tip_amount);

    printf("Do you want to pay the tip (y/n)? ");

    scanf("%c", &choice);

    // Set the tip amount to 0 if the

    // user enters no.

    if(choice == 'n' || choice == 'N')

    {

        tip_amount = 0;

    }

    // Compute the tax amount and the total amount.

    tax_amount = bill_amount * 0.0825;

    total = bill_amount + tax_amount + tip_amount;

    // Display all the information to the user.

    printf("\nBill amount = %f\n", bill_amount);

    printf("Tax amount = %f\n", tax_amount);

    printf("Tip amount = %f\n", tip_amount);

    printf("Total amount = %f\n", total);

    // Return 0 and exit the program.

    return 0;

}

Add a comment
Know the answer?
Add Answer to:
Bill and Tip Calculator Write a C program to generate a receipt for a restaurant. Your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C  program that computes the tax and tip on a restaurant bill for a patron...

    Write a C  program that computes the tax and tip on a restaurant bill for a patron with a $88.67 meal charge. The tax should be 6.75 percent of the meal cost. The tip should be 20 percent of the total after adding the tax. Display the meal cost, tax amount, tip amount, and total bill on the screen.

  • CIT 238 – Android Programming I Tip Calculator Create an app that will compute the tip...

    CIT 238 – Android Programming I Tip Calculator Create an app that will compute the tip on a restaurant bill. App should contain: • An EditText to allow the user to enter the total amount of the bill • RadioButtons to allow the user to select one of the given tip percentages o 10% tip o 15% tip o 20% tip • A Button to calculate the amount of the tip. • A TextView to display the tip amount (tip...

  • Python Simple Programming Write a program in Python that calculates the tip and total for a...

    Python Simple Programming Write a program in Python that calculates the tip and total for a meal at a restaurant. When your program is run it should ... Calculate the tip and total for a meal for a restaurant Print the name of the application "Tip Calculator" Get input from the user for cost of meal and tip percent Print the tip and total amounts. The formula for calculating the tip amount is: tip = cost of meal * (tip...

  • in C# Write an object-oriented program that can be used to determine the tip amount that...

    in C# Write an object-oriented 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 the taxes (9% of the total) and the tip charge of 15%. Produce output showing the calculated total amount due. Tax should be added to the bill before the tip is determined. i will rate if correct

  • Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill...

    Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill amount from the command-line, then show 3 tip amounts: 15%, 20% and 25% of the bill. Don't worry about rounding the result to two decimal places, but make sure that the result includes cents (not just dollars). This program will be different than your first Tipcalc program because you will writea method to calculate the tip amount. program will have 2 methods: main) and...

  • write a java code to calculate a restaurant tip based on the diner’s satisfaction on a...

    write a java code to calculate a restaurant tip based on the diner’s satisfaction on a scale of 1 – 5. The user will input the total bill and their rating. The program should output the tip percentage, tip amount, and total due. You must use a select statement instead of an if. For a rating of 1, calculate a 10 % tip. For a rating of 2, calculate a 12.5% tip. For a rating of 3, calculate a 15...

  • Language - PYTHON Design a program that calculates the total amount of a meal purchased at a restaurant

    Language - PYTHONDesign a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of a 15% tip and 7% sales tax. Display each of these amounts and the total.Please help, I have no idea where to begin. Thanks

  • Create a script to make a receipt for a restaurant purchase. Your script should repeatedly take s...

    How do i do this with Python? Create a script to make a receipt for a restaurant purchase. Your script should repeatedly take sales until the user hits a "d" to signal they are done. Your script should report the subtotal, tax, tip and total amount of the sale. Tax is 6%. Tip is based on the sale. For sales under S 15.00, the tip is 10%, for sales between $15 and $50, the tip is 15% and for sales...

  • When you go to a restaurant you need to calculate the tip that you need to...

    When you go to a restaurant you need to calculate the tip that you need to give the waiter. Write a program that allows a user to enter the total bill, and whether g-good service, a-all right, n-not bad, p-poor. Percentages for the service levels are: g-good service=25%,a-all right=15%,n-not bad=10%,p-poor= 0% . Calculate the tip. Add validation of the input, round up the tip amount and change the background color to green for good service, pink for all right, orange...

  • python - Write a program that asks the user to enter how much their dinner bill...

    python - Write a program that asks the user to enter how much their dinner bill was. Then ask them how many people were in their party. If there were more than 6 people in their party automatically calculate a 20% tip. If there were 6 or less people in their party ask them what percentage they would like to tip. In all cases, print out the total amount of the tip at the end of the program.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT