Java Programming Coursework: Complete Pizza Order System Code
VerifiedAdded on  2020/07/23
|11
|1011
|95
Homework Assignment
AI Summary
This assignment provides a Java code solution for a pizza order system, designed to meet the requirements of a coursework project. The code allows users to input their preferences for pizza size (small, medium, large), crust type (deep pan, thin crust, stuffed crust), and toppings (pineapple, anchovy). The program uses conditional statements to process user input and determine the pizza's characteristics. The code includes variables for pizza attributes like crust, sauce, and toppings, along with calculations for cost, tax, and total amount due. The system takes user inputs and provides a customized pizza order. The program also incorporates input validation to handle different user inputs and ensure the system functions correctly. Screenshots of the code and its output are also provided.

JAVA COURSEWORK
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

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()
{
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

// 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) {
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

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 :
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

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.
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

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
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.
