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]
2 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]2 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
This assignment is to code a simple hangman game. The game should choose a random word out of a list of words that are coded int
pshichka [43]

Answer:

Programming language not stated.

I'll use python for this question

Explanation:

import random

# library that we use in order to choose

# on random words from a list of words

words = ['rain, 'computer', 'science', 'program, 'python', 'mathematics', 'player', 'condition','reverse', 'water', 'board', 'geeks','learn','school','days','scholar','collar','flood','house','flies']

# Function will choose one random word from this list of words

word = random.choice(words)

print("Guess the word")

guesses = ''"

# 5 turns

turns = 5

while turns > 0:

# counts the number of times a user fails

failed = 0

# all characters from the input word taking one at a time.

for char in word:

# comparing that character with the character in guesses

if char in guesses:

print(char)

else:

print("_")

# for every failure 1 will be incremented in failure

failed += 1

if failed == 0:

# user will win the game if failure is 0 and 'You Win' will be given as output

print("You Win")

# this print the correct word

print("The word is: ", word)

break

# if user has input the wrong alphabet then it will ask user to enter another alphabet

guess = input("guess a character:")

# every input character will be stored in guesses

guesses += guess

# check input with the character in word

if guess not in word:

turns -= 1

# if the character doesn’t match the word then “Wrong” will be given as output

print("Wrong")

# this will print the number of turns left for the user

print("You have", + turns, 'more guesses')

if turns == 0:

print("You Loose")

7 0
2 years ago
is there a way to send files from my PC to my iPhone? My PC’s wifi receptors are broken so it cannot connect to wifi. Is there a
Alex_Xolod [135]

Answer:

I believe you need a internet connection for that or try a Hotspot that can work too.

5 0
3 years ago
The concept that allows certain professions to use copyrighted material without permission in their work is called _____.
lesantik [10]
C) fair use

Hope this helps... mark as Brainliest plz
4 0
3 years ago
Rajesh is considering whether to use a web app to collaborate with a group of friends on a project. What is one reason he should
vivado [14]

Rajesh might want to avoid the use of a web app for the project due to connectivity issues. Hence, one reason he might want to avoid using the Webb app is slow or poor internet connection.

Collaborating on a web application relies very heavily on network connectivity which is the what establishes the link ms allows the apllications to achieve optimum performance.

Therefore, slow internet connection is a major reason whuhe might want to avoid using a web app.

Learn more : brainly.com/question/25531734

6 0
2 years ago
in triangle abc the value of cot a by 2 into cot B by 2 minus 1 whole divided by cot a by 2 into cot B by 2 is equal to​
netineya [11]

Answer: 2 + 2 is 4 minus 1 thats 3 quick mafs

Explanation:

8 0
3 years ago
Other questions:
  • What is the definition of framerate?
    7·1 answer
  • What are issues to consider when deciding to build software in-house or purchase commercial off-the-shelf software (cots)?
    14·1 answer
  • Consider the following code segment.
    15·1 answer
  • Match the following:
    13·1 answer
  • Celeste is writing a paper. However, two pages in, her computer shuts down unexpectedly. She never saved her paper, and all her
    12·2 answers
  • PLZ HELP ME! <br> Write pseudocode for getting a bowl of ice cream using at least four steps.
    11·1 answer
  • Sharl downloads images from an online library and uses them in her work. The images are shared under the Creative Commons Attrib
    13·1 answer
  • Leslie works in an SDLC team. When Leslie edits a file, it gets saved as an altered version. Later all the altered versions are
    9·1 answer
  • There is overlap in the subjects of study in the different information technology disciplines. true or false
    15·1 answer
  • what is one benefit of placing voip gateways in geographically separated branch offices that have an existing wan connection?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!