Question

In: Computer Science

Java program for food bill There are N friends went to a restaurant and after having...

Java program for food bill

There are N friends went to a restaurant and after having the meal, they want to divide the bill amount equally among them. Please write a java code to obtain the bill amount, the percentage of tax and number of people from the user. Your code should compute Total Bill amount, tax amount, and each person’s share. Where, Total bill amount= bill amount+ tax amount For example, if bill amount=100.00$ Percentage of taxes= 2 % and Number of people=4, then your code has to compute Total bill amount= 102.00 $, Tax amount= 2 $ and share of each person = 25.50 $

Your code should print Bill amount, tax amount, total bill amount, Number of people, and amount to be paid by each person. You may want to use double or floating-point data type for bill amount, tax percentage, and tax amount. To read floating data from keyboard, you may want to use statements as below. Scanner inp=new Scanner(System.in); billamount=inp.nextFloat();

Solutions

Expert Solution

// FoodBill.java : Java program to create a program for food bill that displays the share of each person

import java.util.Scanner;

public class FoodBill {

       public static void main(String[] args) {

             double bill_amount, tax_percent, tax, total_amount;

              int num_people;

            

             Scanner scan = new Scanner(System.in);

             // input of bill amount

             System.out.print("Enter the bill amount : ");

             bill_amount = scan.nextDouble();

             // input of tax as percentage

             System.out.print("Enter the tax percentage : ");

             tax_percent = scan.nextDouble();

             // input of number of people

             System.out.print("Enter the number of people : ");

             num_people = scan.nextInt();

            

             tax = (bill_amount*tax_percent)/100; // calculate the total tax on the bill

             total_amount = bill_amount + tax; // calculate the total bill amount

            

             // print the bill amount, tax, total bill amount, number of people and each person's share

             System.out.printf("\nBill Amount : $%.2f",bill_amount);

             System.out.printf("\nTax Amount : $%.2f",tax);

             System.out.printf("\nTotal Bill Amount : $%.2f",total_amount);

             System.out.printf("\nNumber of people : %d",num_people);

             System.out.printf("\nAmount paid by each person : $%.2f",(total_amount/num_people));

            

             scan.close();

       }

}

//end of program

Output:


Related Solutions

A random sample of n = 81 customers at a fast-food restaurant had a mean bill...
A random sample of n = 81 customers at a fast-food restaurant had a mean bill of x̅ = $10.71. If the population standard deviation is σ = $3.42, find the 97% confidence interval (including units) of the mean bill for all customers. Assume the variable is normally distributed and state the distribution used to find the interval. Distribution used: Confidence interval: The average age of a sample of n = 73 mayors was x̅ = 46.9 years with a...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for the check amount, then ask the user what type of tipp they would like to leave: the choices are 1 for good tip (20%), 2 for an average tip (15%), or 3 for poor tip (10%). Use their input and an if-else to calculate the tip amount. Then calculate and output the final bill: check+tip print out the bill, exactly as shown (print the...
Write a program that computes the tax and tip on a restaurant bill for a patron...
Write a program that computes the tax and tip on a restaurant bill for a patron with $44.50 meal charge. The tax should be 6.75% of the meal cost. The tip should be 15% of the total after adding tax. Display the meal cost, tax amount, tip amount, and total bill on the screen. (I need this to be in OOP using C++)
Restaurant Selector IN JAVA You have a group of friends coming to visit for your high...
Restaurant Selector IN JAVA You have a group of friends coming to visit for your high school reunion, and you want to take them out to eat at a local restaurant. You aren’t sure if any of them have dietary restrictions, but your restaurant choices are as follows: Joe’s Gourmet Burgers – Vegetarian: No, Vegan: No, Gluten-Free: No Main Street Pizza Company – Vegetarian: Yes, Vegan: No, Gluten-Free: Yes Corner Café – Vegetarian: Yes, Vegan: Yes, Gluten-Free: Yes Mama’s Fine...
John and Eric are childhood friends who went to school and university together. After graduation, John...
John and Eric are childhood friends who went to school and university together. After graduation, John moved to Spain where he joined his family and started a business exporting authentic Spanish Artwork to clients around the World. Eric operates a retail store in Brazil, and the two friends agreed to start a business together. John would send artwork to Eric who would sell it in his store at a reasonable price. John shipped the Artwork by mail to ensure quick,...
John and Eric are childhood friends who went to school and university together. After graduation, John...
John and Eric are childhood friends who went to school and university together. After graduation, John moved to Spain where he joined his family and started a business exporting authentic Spanish Artwork to clients around the World. Eric operates a retail store in Brazil, and the two friends agreed to start a business together. John would send artwork to Eric who would sell it in his store at a reasonable price. John shipped the Artwork by mail to ensure quick,...
Erika ate dinner at the Cypress Restaurant. After dinner she paid the cashier and went home...
Erika ate dinner at the Cypress Restaurant. After dinner she paid the cashier and went home without realizing she had left her purse at the restaurant. What liability does the restaurant have if the cashier does not notice the purse and it is stolen? What liability does the restaurant have if the cashier takes possession of the purse intending to notify Erika that it is at the restaurant? Draft a 250 - 300 word discussion explaining the your answer in...
Write a Java program for a restaurant with the following features: ◦ Customer: Name, Surname, ID...
Write a Java program for a restaurant with the following features: ◦ Customer: Name, Surname, ID (incremental ID by 1 for each new customer), Email, Phone, Address. ◦ Service: ID (incremental ID by1 for each group),CustomerID, Priority (High, Medium, Low, Other), ResolutionTimeFrame (Measured in Man hours), AssignedUser, Status(resolved or not), Fee. ◦ User (simple user of system): ID, Name, Surname, Username and Password (insert from code five fixed users), Address , PhoneNumber ◦ Manager: Name, Surname, Username and Password (insert...
A large fast-food restaurant is having a promotional game where game pieces can be found on...
A large fast-food restaurant is having a promotional game where game pieces can be found on various products. Customers can win food or cash prizes. According to the company, the probability of winning a prize (large or small) with any eligible purchase is 0.131. Consider your next 32 purchases that produce a game piece. Calculate the following: This is a binomial distribution. Round your answers to at least 4 decimal places. a) What is the probability that you win 5...
A large fast-food restaurant is having a promotional game where game pieces can be found on...
A large fast-food restaurant is having a promotional game where game pieces can be found on various products. Customers can win food or cash prizes. According to the company, the probability of winning a prize (large or small) with any eligible purchase is 0.192. Consider your next 34 purchases that produce a game piece. Calculate the following: This is a binomial distribution. Round your answers to 4 decimal places. a) What is the probability that you win 7 prizes? b)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT