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
Which of these is NOT one of the main parts of an email? A. Header B. Subject C. Body D. Reply
7nadin3 [17]
D. Reply.
<u><em>Brainiest PLEASE!
</em></u>

7 0
3 years ago
Read 2 more answers
Is the address 7b invalid regarding cell references?
Lubov Fominskaja [6]

Answer:

It is not valid

Explanation:

I'll assume the question relates to cell referencing in Microsoft Excel.

To reference a cell in Excel, we make use of the following steps:

  • Write out the cell column name first
  • Followed by the row number

7b implies that, the row number first, followed by the column name; this doesn't follow the naming convention of cells.

Hence, 7b is invalid.

3 0
3 years ago
What's internet reendorsement?
Soloha48 [4]
Good question. When one Endorces or "Hires/ payes" someone again for a job/thing they did. I think. :)
6 0
3 years ago
2. Choose all of the correct answers for each of the following: [a] The relations of two sub-entity sets of the same super entit
Andrews [41]

Answer:

i say b

Explanation:

5 0
2 years ago
Describe how keyboard software works and which problems does keyboard software<br> need to handle?
Anastaziya [24]

Answer:

The target computer's operating system and gain unauthorized access to the hardware, hook into the keyboard with functions provided by the OS, or use remote access software to transmit recorded data out of the target computer to a remote location.

No physical sensation of pressing a button results in misfires. Lack of physical divisions between keys makes touch typing impossible. Smaller key spacing results in typos.

3 0
3 years ago
Other questions:
  • Dominick has been hired to design a network for Pirate Press. In a paragraph of no less than 125 words, discuss what he needs to
    12·2 answers
  • file Assume that a prototype of the part above was built from several cubes. The total volume of the part is 0.54675 in.3. What
    6·1 answer
  • Select the correct answer.
    9·1 answer
  • A friend is having a problem with keeping a fish tank at the right temperature so the fish stay healthy. Describe how you could
    9·1 answer
  • What are the characteristics of a severe storm
    12·1 answer
  • Malwar is the short form for malicious software and used to refer​
    14·1 answer
  • If a fire should break out in your building, which of the following actions is NOT recommended?
    10·2 answers
  • Macro photographs are what type of photographs? A. Close-up B. Telephoto C. Abstract D. All of the above
    14·1 answer
  • A computer with the ability to store instructions and do the job when requested by the operator, this type of computer had a spe
    12·1 answer
  • BRIANLIEST!!!!!!!!!!!!!!!!
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!