Implementation of Pizza Order System using Java

Verified

Added 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.
Document Page
JAVA COURSEWORK

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
TABLE OF CONTENTS
Pizza Order System.....................................................................................................................................2
Code........................................................................................................................................................2
Document Page
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()
{
Document Page
// 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) {

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
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)");
Document Page
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 :
Document Page
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.

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
Document Page
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.
Document Page

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
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.
1 out of 11
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]