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
What is folded card publishing?​
Alexeev081 [22]

Answer:

Folded card This layout type is for creating greeting cards by printing pages on a sheet and then folding the sheet to make the card. If you choose the Folded card layout, then sheet fold options are displayed. Select an option in the list to specify how you will fold your publication

Explanation:

3 0
1 year ago
Read 2 more answers
What should you do if a headset plugged into your computer is not working properly?
Alex777 [14]

If a headset plugged into computer is not working properly than one can go for updating the device driver. The correct option is B.

<h3>What is a device driver?</h3>

A device driver is a type of software application that allows one hardware device (such as a computer) to communicate with another hardware device (such as a printer). A device driver is indeed referred to as a software driver.

A driver, also known as a device driver, is a collection of files that instructs a piece of hardware on how to operate by communicating with a computer's operating system.

Every piece of hardware, from internal computer components like your graphics card to external peripherals like a printer, requires a driver.

If a headset plugged into a computer is not working properly, the device driver can be updated.

Thus, the correct option is B.

For more details regarding device driver, visit:

brainly.com/question/14054807

#SPJ12

8 0
11 months ago
Read 2 more answers
What is the answer to this question I am not sure?
aleksley [76]

Answer:

Light sensor

Explanation:

“Street Light that Glows on Detecting Vehicle Movement. Generally, street light controlling system is a simple concept which uses a transistor to turn ON in the night time and turn OFF during the day time. The entire process can be done by a using a sensor namely LDR (light dependent resistor).”

8 0
3 years ago
Read 2 more answers
What does the Disk Defragmenter tool do?
rusak2 [61]
 It's kind of a mix between A and C there are some defragmenting tools that show you how much of your PC is wasted by program files. And in some defragmenting tools, it shows you all the files that are fragmented and gives you the option to defrag them or not. So the best answer would be A.  
7 0
3 years ago
Write a program with a main method that asks the user to enter an array of 10 integers. Your main method then calls each of the
Kay [80]

Answer:

The remaining part of the question is given as follows:

printReverse - a void method that reverses the elements of the array and prints out all the elements in one line separated by commas (see sample output below).

getLargest - an int method that returns the largest value in the array.

computeTwice- a method that returns an array of int which contains 2 times of all the numbers in the array (see the sample output below).

Explanation:

// Scanner class is imported to allow the program receive

// user input

import java.util.Scanner;

// Arrays class is imported to allow the program display the array

// in a pretty way

import java.util.Arrays;

//The class definition

public class Solution {

   // main method is defined which signify beginning of program

  // execution

   public static void main(String[ ] args) {

       // an array is initialized with a size of 10

       int[] array =new int[10];

       // Scanner object scan is defined

       Scanner scan =new Scanner(System.in);

       // A loop is initiated to receive 10 user input to fill the array

       for(int i=0; i < 10; i++){

           System.out.print("Please enter number: ");

           array[i]=scan.nextInt();

       }

       

       // A blank line is print

       System.out.println();

       // printReverse method is called with the received array as

      // argument

       printReverse(array);

       // A blank line is print

       System.out.println();

       // The largest number is printed

       System.out.println("The largest number is: " + getLargest(array));

       // computeTwice method is called to display the array after

      // multiplying each element by 2

       computeTwice(array);

       System.out.println( "The values of the computed twice array is: " );

       // Arrays class is used to print the array in form of a string

      // not object

       System.out.println(Arrays.toString(array));

   }

   

   //printReverse method declared with inputArray as parameter.

   // It has no return type

   public static void printReverse(int[] inputArray){

       System.out.print("Here is the arrray in reverse order: ");

       // A loop goes through the array starting from the end

       // and display each element

       for(int i = (inputArray.length - 1); i >= 0; i--){

           if(i == 0){

               // If the last element, do not append comma

               System.out.print(inputArray[i]);

           } else {

               // If not the last element, do append a comma

               System.out.print(inputArray[i] + ", ");

           }

       }

   }

   

   // getLargest method is declared with inputArray as parameter

   //  it compare each element in the array and return the largest

   public static int getLargest(int[] inputArray){

       // The first element is assumed to be the largest before the

      // loop begin

       int max = inputArray[0];

       for(int i = 1; i < inputArray.length; i++){

           if (inputArray[i] > max){

               max = inputArray[i];

           }

       }

       return max;

   }

   

   // computeTwice is declared with inputArray as parameter

   // it loop through the array and multiply each element by 2

   // it then return a modified array

   public static int[] computeTwice(int[] inputArray){

       for(int i = 0; i < inputArray.length; i++){

           inputArray[i] *= 2;

       }

       return inputArray;

   }

}

8 0
3 years ago
Other questions:
  • What is intensity? this is for digital arts
    12·1 answer
  • List two reasons why “buying a computer is no easy task” ?
    12·2 answers
  • Which number is the decimal equivalent of 1100110 – 101101?
    13·2 answers
  • List pros and cons of HCI technology​
    5·2 answers
  • Write a program to generate following series in qbasics 100,81,64,....1​
    13·1 answer
  • Who do you guys ship lol bit with?
    14·2 answers
  • We can use formatting before and after typing.​
    8·1 answer
  • Whose work is responsible for the invention of the air bag? Scientist, Engineers or both?
    12·1 answer
  • Can someone reply me
    11·1 answer
  • What is control structure write it's types​ .
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!