1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dahasolnce [82]
3 years ago
14

You and a few friends are having a meal at a pizza restaurant, and the server has just given you the bill. Write a function that

asks the user how many people there are total and what percent they'd like to tip the server. Then, given the cost of the pizza and the tax rate as a percentage, calculate the total cost of the meal and return how much each person must pay rounded to 2 decimal places. Note that the tax should be calculated and added to the total, and the tip amount should be determined based on the total including tax. Additionally, you may assume that the parameters will always follow the types listed above. The user will always pass in an integer for the number of people, but the tip could be either an int or a float. The percentages given for tax and tip will always be between 0 and 1 inclusive. There will always be at least one person.
Function name : split_bill()
Parameters : pizza_cost (int), tax_percent (float)
Returns: total_cost (float)
Computers and Technology
1 answer:
cestrela7 [59]3 years ago
8 0

Answer:

How to calculate the total cost of the meal

For bill inclusive of tax, cost1=cost*(1+tax percentage)

For bill inclusive of tax and tip, cost2=cost1*(1+tip percentage)

Meal cost =(pizza cost*(1+tax percentage))*(1+tip percentage)

Now how to calculate the cost per person

cost per person=meal cost/ number of people.

C language code to solve the above problem is given below with appropriate comments for explanation

Explanation:

#include<stdio.h>

float split_bill(int cost,float tax)

{

//Declaring number of people as int

int number;

//Prompting for number of people

printf("Enter number of people ");

scanf("%d",&number);

//Declaring tip percentage as float

float tip_percent;

//Prompting for tip percentage

printf("Enter tip percentage between 0 and 1 ");

scanf("%f",&tip_percent);

//Calculating total meal cost

float meal=(((float)cost)*(1+tax))*(1+tip_percent);

//Printing total cost of meal

printf("Total cost of meal: %0.2f ",meal);

//Calculating cost per person

float cost_per_person=meal/number;

//Returning cost per person to main function

return cost_per_person;

}

int main()

{

//Declaring pizza cost as int and tax percentage as float

int pizza_cost;

float tax_percent;

//Prompting user for pizza cost

printf("Enter billing amount of pizza ");

scanf("%d",&pizza_cost);

//Prompting user for tax percentage

printf("Enter tax percentage between 0 and 1 ");

scanf("%f",&tax_percent);

//Printing the cost per person by calling the function split_bill

printf("Total cost per person is: %0.2f ",split_bill(pizza_cost,tax_percent));

return 0;

}

You might be interested in
Think about how you view your emails—either the email service you use yourself or an email service you would choose to use. Desc
Assoli18 [71]

Answer:

and POP3, followed in later years. POP3 is still the current version of the protocol, though this is often shortened to just POP. While POP4 has been proposed, it's been dormant for a long time.

IMAP, or Internet Message Access Protocol, was designed in 1986. Instead of simply retrieving emails, it was created to allow remote access to emails stored on a remote server. The current version is IMAP4, though most interfaces don't include the number.

The primary difference is that POP downloads emails from the server for permanent local storage, while IMAP leaves them on the server while caching (temporarily storing) emails locally. In this way, IMAP is effectively a form of cloud storage.

7 0
2 years ago
When companies want people to think their brand is wholesome, trustworthy, and confident, this is the color most often chosen.
notsponge [240]
A. Blue. When you want to be viewed as trustworthy and cool you would use the color blue.
6 0
3 years ago
Read 2 more answers
What will be a fundamental aspect of future games?
padilas [110]
D. product- oriented :))
6 0
3 years ago
Read 2 more answers
An _____ is a narrow strip of land connecting two larger land areas.
inessss [21]

Answer: isthmus

Explanation:

5 0
3 years ago
This type of program is designed to be transmitted over the internet and run in a web browser
vodomira [7]
This sounds like a web-based application because they are designed to be ran within a website, generally with Adobe Flash.
8 0
3 years ago
Other questions:
  • ____ is a practice where a user in enticed by possible rewards and then asked to provide personal information.
    14·1 answer
  • What is processor, memory RAM, cDRAM,DVD RAM,video card​
    9·1 answer
  • Which of the following is NOT a destination?
    12·2 answers
  • Which of the following is considered a benefit when using slab allocator?
    6·1 answer
  • a(n) ___ loop allows you to cycle through an array without specifying the starting and ending points for the loop
    14·1 answer
  • A network administrator for a small company is contemplating how to scale the network over the next three years to accommodate p
    13·1 answer
  • You need to update both the DEPARTMENT_ID and LOCATION_ID columns in the EMPLOYEES table using one UPDATE statement. Which claus
    5·1 answer
  • 1. Explain the difference between a web browser and a search engine. (2 points)
    8·1 answer
  • In one to two sentences, describe how you would add a new slide to your presentation.
    11·2 answers
  • What are the sectors of the buisness enviornment
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!