Implementation of Pizza Order System using Java
VerifiedAdded on  2020/07/23
|11
|1011
|95
AI Summary
This assignment involves implementing a pizza order system in Java. The system allows users to select from different pizza sizes, crust types, toppings, and sauce options. It then calculates the total cost of the order, including tax. The code includes several conditional statements to handle user input validation and ensure that the correct calculations are performed based on the selected options.
Contribute Materials
Your contribution can guide someone’s learning journey. Share your
documents today.
JAVA COURSEWORK
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
TABLE OF CONTENTS
Pizza Order System.....................................................................................................................................2
Code........................................................................................................................................................2
Pizza Order System.....................................................................................................................................2
Code........................................................................................................................................................2
Pizza Order System
The following code covers all the basic requirements that are needed as the users who want to
order a pizza should ensure that the overall size for pizza choices is restricted to 6 whereas the user is free
to choose either zero, one or two toppings. As per the instructions, the toppings that can be used in this
project are either pineapple or anchovy. The base and crust of pizza can also be classified in three types.
So, all the required factors have been involved in the following code.
Code
import java.util.Scanner;
public class Pizza
{
String firstname = "xx";
char crusttype;
String crust;
String sauce;
String base1 = "small";
String base2 = "medium";
String base3 = "large";
int inches = 0;
double cost = 0.0;
final double taxrate=0.00;
double tax;
double total;
double Ltotal;
int numberoftoppings =6;
String Firsttopping = "pineapple";
String Secondtopping = "anchovy";
/**
* Constructor for objects of class Pizza
*/
public Pizza()
{
The following code covers all the basic requirements that are needed as the users who want to
order a pizza should ensure that the overall size for pizza choices is restricted to 6 whereas the user is free
to choose either zero, one or two toppings. As per the instructions, the toppings that can be used in this
project are either pineapple or anchovy. The base and crust of pizza can also be classified in three types.
So, all the required factors have been involved in the following code.
Code
import java.util.Scanner;
public class Pizza
{
String firstname = "xx";
char crusttype;
String crust;
String sauce;
String base1 = "small";
String base2 = "medium";
String base3 = "large";
int inches = 0;
double cost = 0.0;
final double taxrate=0.00;
double tax;
double total;
double Ltotal;
int numberoftoppings =6;
String Firsttopping = "pineapple";
String Secondtopping = "anchovy";
/**
* Constructor for objects of class Pizza
*/
public Pizza()
{
// initScanner keyboard = new Scanner(System.in);
}
public static void main (String[] args) {
Scanner keyboard = new Scanner(System.in);
String firstname = "xx";
char crusttype;
String crust;
String sauce;
String base1 = "small";
String base2 = "medium";
String base3 = "large";
int inches = 0;
double cost = 0.0;
final double taxrate=0.00;
double tax;
double total;
double Ltotal;
int numberoftoppings =6;
String Firsttopping = "pineapple";
String Secondtopping = "anchovy";
System.out.println ("Enter the name :");
double distance = 0;
System.out.println ("What size will you prefer???");
inches = keyboard.nextInt();
if (inches == 10) {
System.out.println("base1");
}
if (inches == 12) {
}
public static void main (String[] args) {
Scanner keyboard = new Scanner(System.in);
String firstname = "xx";
char crusttype;
String crust;
String sauce;
String base1 = "small";
String base2 = "medium";
String base3 = "large";
int inches = 0;
double cost = 0.0;
final double taxrate=0.00;
double tax;
double total;
double Ltotal;
int numberoftoppings =6;
String Firsttopping = "pineapple";
String Secondtopping = "anchovy";
System.out.println ("Enter the name :");
double distance = 0;
System.out.println ("What size will you prefer???");
inches = keyboard.nextInt();
if (inches == 10) {
System.out.println("base1");
}
if (inches == 12) {
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
System.out.println("base2");
}
if (inches == 14) {
System.out.println("base3");
}
keyboard.nextLine();
System.out.println ("What type of crust you want, (D)eep Pan, (T)hin crust, (S)tuffed crust ?");
crusttype = keyboard.nextLine().charAt(0);
if (crusttype == 'D' || crusttype == 'd') {
crust = "Deep Pan";
}
else if (crusttype == 'T' || crusttype == 't') {
crust = "Thin crust";
}
else if (crusttype == 'S' || crusttype == 's') {
crust = "Stuffed crust";
}
else if (crusttype != 'D' || crusttype != 'd' && crusttype != 'T' || crusttype != 't'&& crusttype != 'S' ||
crusttype != 's') {
crust = "Deep Pan";
System.out.println("All crusts come with a tomato sauce and mozzarella topping");
System.out.println ("Tomato sauce can be changed to BBQ at 50p, either for topping, choose from
Pineapple or anchovy");
System.out.println("Do you want Pineapple? (Y/N)");
if (numberoftoppings=='Y' || numberoftoppings=='y') {
numberoftoppings = numberoftoppings + 1;
Firsttopping = Firsttopping + " and Pineapple";
}
else {
}
System.out.println("Do you want Anchovy? (Y/N)");
}
if (inches == 14) {
System.out.println("base3");
}
keyboard.nextLine();
System.out.println ("What type of crust you want, (D)eep Pan, (T)hin crust, (S)tuffed crust ?");
crusttype = keyboard.nextLine().charAt(0);
if (crusttype == 'D' || crusttype == 'd') {
crust = "Deep Pan";
}
else if (crusttype == 'T' || crusttype == 't') {
crust = "Thin crust";
}
else if (crusttype == 'S' || crusttype == 's') {
crust = "Stuffed crust";
}
else if (crusttype != 'D' || crusttype != 'd' && crusttype != 'T' || crusttype != 't'&& crusttype != 'S' ||
crusttype != 's') {
crust = "Deep Pan";
System.out.println("All crusts come with a tomato sauce and mozzarella topping");
System.out.println ("Tomato sauce can be changed to BBQ at 50p, either for topping, choose from
Pineapple or anchovy");
System.out.println("Do you want Pineapple? (Y/N)");
if (numberoftoppings=='Y' || numberoftoppings=='y') {
numberoftoppings = numberoftoppings + 1;
Firsttopping = Firsttopping + " and Pineapple";
}
else {
}
System.out.println("Do you want Anchovy? (Y/N)");
if (numberoftoppings=='Y' || numberoftoppings=='y') {
numberoftoppings = numberoftoppings + 1;
Secondtopping = Secondtopping + " and Anchovy";
}
else {
if (numberoftoppings=='N' || numberoftoppings=='n')
System.out.println("you don't want any topping. Thankyou");
}
System.out.println (cost);
System.out.println (numberoftoppings);
total = (cost) + (numberoftoppings * 1.25);
tax = total * taxrate;
Ltotal = total + (1 + taxrate);
System.out.println (firstname + ", your order :)");
System.out.println (inches + "inch pizza");
System.out.println (crust + "toppings");
System.out.println ("Order cost : $ + (total)");
System.out.println ("Tax: $");
System.out.println ("Total Due : $");
}
}
}
The screenshots of the following code with output are represented as under :
numberoftoppings = numberoftoppings + 1;
Secondtopping = Secondtopping + " and Anchovy";
}
else {
if (numberoftoppings=='N' || numberoftoppings=='n')
System.out.println("you don't want any topping. Thankyou");
}
System.out.println (cost);
System.out.println (numberoftoppings);
total = (cost) + (numberoftoppings * 1.25);
tax = total * taxrate;
Ltotal = total + (1 + taxrate);
System.out.println (firstname + ", your order :)");
System.out.println (inches + "inch pizza");
System.out.println (crust + "toppings");
System.out.println ("Order cost : $ + (total)");
System.out.println ("Tax: $");
System.out.println ("Total Due : $");
}
}
}
The screenshots of the following code with output are represented as under :
As the crossed lines have been erased, it means that the program has been compiled successfully. Also, it
means that all the errors have been resolved and the code has been compiled successfully.
means that all the errors have been resolved and the code has been compiled successfully.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
The screenshot represents all the variables that have been included in the code and are essential to be
involved in order to complete the requirements of the pizza order system.
involved in order to complete the requirements of the pizza order system.
Secure Best Marks with AI Grader
Need help grading? Try our AI Grader for instant feedback on your assignments.
This output asks the user for their preference so that on the basis of that the pizza can be ordered and then
delivered to the user. As in this case, D is entered by the user, so the pizza order system will order a deep
pan crust for the pizza that has been ordered. If the user will enter any other input which is other than D,
d, T, t, S and s, then by default, the pizza order system will input the deep pan crust to the pizza that has
been ordered by the user.
delivered to the user. As in this case, D is entered by the user, so the pizza order system will order a deep
pan crust for the pizza that has been ordered. If the user will enter any other input which is other than D,
d, T, t, S and s, then by default, the pizza order system will input the deep pan crust to the pizza that has
been ordered by the user.
1 out of 11
Related Documents
Your All-in-One AI-Powered Toolkit for Academic Success.
 +13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
© 2024  |  Zucol Services PVT LTD  |  All rights reserved.