

/***************************************Buffet.java**********************************/
public class Buffet {
/*
* data field
*/
private String name;
private String location;
public Buffet(String name, int location) {
this.name = setName(name);
this.location =
setLocation(location);
}
public String setName(String name) {
String name1 = name.toUpperCase().charAt(0) + name.substring(1, name.length()).toLowerCase() + " Buffet";
return name1;
}
public String setLocation(int location) {
String location1 = "";
switch (location) {
case 21204:
location1 =
"Township\n" + "--------" + "\nAll you can eat Buffet at a great
price!!!";
break;
case 21237:
location1 =
"Rosedale" + "\n\t\t\t --------" + "\nAll you can eat Buffet at a
great price!!!";
break;
default:
location1 =
"Baltimore" + "\n\t\t\t ---------" + "\nAll you can eat Buffet at a
great price!!!";
break;
}
return location1;
}
@Override
public String toString() {
return "\t\t\t"+name + "\n\t\t\t
" + location;
}
}
/*******************************Bill.java*******************************/
import java.text.NumberFormat;
public class Bill {
/*
* data field
*/
static final double TAXRATE = .06;
private String category;
private int mealQty;
private double mealCost;
private double mealPrice;
public Bill() {
this.category = null;
this.mealQty = 0;
this.mealCost = 0;
this.mealPrice = 0;
}
public double calcAdultCost(int numberOfAdults) {
double mealCost;
this.mealQty =
numberOfAdults;
this.category = "Adults";
this.mealPrice = 31.50;
if (numberOfAdults < 9) {
mealCost =
mealPrice * mealQty;
} else {
mealCost =
mealPrice * mealQty - 5.00;
}
this.mealCost = mealCost;
return mealCost;
}
public double calcChildCost(int numberOfChilds) {
double mealCost;
this.mealQty =
numberOfChilds;
this.category = "Adults";
this.mealPrice = 15.00;
if (numberOfChilds <= 3) {
mealCost =
mealPrice * mealQty;
} else {
mealCost =
mealPrice * 3;
}
this.mealCost = mealCost;
return mealCost;
}
public static double calTax(double total) {
return total * TAXRATE;
}
public void display() {
NumberFormat f = NumberFormat.getCurrencyInstance();
System.out.println("\t" +
category + "\t\t" + mealQty + "\t" + f.format(mealPrice) + "\t" +
f.format(mealCost));
}
}
/*********************************BuffetDemo.java************************************/
import java.text.NumberFormat;
import java.util.Scanner;
public class BuffetDemo {
public static void main(String[] args) {
Scanner scan = new
Scanner(System.in);
double total = 0;
NumberFormat f =
NumberFormat.getCurrencyInstance();
System.out.print("\tEnter the name
of Buffet: ");
String name =
scan.nextLine();
System.out.print("\tEnter the
ZipCode: ");
int zipCode = scan.nextInt();
Buffet buffet = new Buffet(name,
zipCode);
int numberOfAdults;
boolean choice = true;
do {
System.out.print("\n\tEnter the number of Adults (-1 to stop)..
");
numberOfAdults =
scan.nextInt();
if
(numberOfAdults < 0) {
choice = false;
} else {
System.out.print("\tEnter the number of Childs:
");
int numberOfChilds = scan.nextInt();
Bill adultBill = new Bill();
Bill childBill = new Bill();
double adultCost =
adultBill.calcAdultCost(numberOfAdults);
double childCost =
childBill.calcChildCost(numberOfChilds);
total = adultCost + childCost;
double tax = Bill.calTax(total);
System.out.println(buffet.toString());
System.out.println("\t\t\t\tPrice\tTotal");
adultBill.display();
childBill.display();
System.out.println();
System.out.println("\tSubtotal\t\t\t\t" +
f.format(total));
System.out.println("\tTax (6%)\t\t\t\t" +
f.format(tax));
System.out.println("\n\t\tTotal Bill\t\t\t" +
f.format(total + tax));
System.out.println("\n");
}
} while (choice);
}
}
/************************output************************************/
Enter the name of Buffet: moNet
Enter the ZipCode: 21237
Enter the number of Adults (-1 to stop).. 9
Enter the number of Childs: 4
Monet
Buffet
Rosedale
--------
All you can eat Buffet at a great price!!!
Price Total
Adults 9
$31.50 $278.50
Adults 4
$15.00 $45.00
Subtotal
$323.50
Tax (6%)
$19.41
Total Bill $342.91
Enter the number of Adults (-1 to stop).. -1

Thanks a lot, Please let me know if you have any problem....................
Write a program for a Buffet to display the bill Sor the cashicr The buffet serves a chef's meu with two options 31 50 The total adu bill is roduced by $5.00 if there are 9 aor more ad $15....
Write a program that computes and displays a customer’s bill for an All-You-Can-Eat Buffet Restaurant. The charge for an adult meal is $6.00 and a child’s (ages 5 to 10) meal is $3.00. The tax rate is 6.5%. The desserts offered at the restaurant are slices of pie at $1.00 per slice. Gratuity is automatically calculated at 15%. Use main( ) as the driver function. Allow the user to process as many customer bills as desired. Use named constants and...