Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Java MyProgrammingLab 4.11) Create a class named Pizza that stores information about a single pizza. It should contain the following: Private instance variables to store

Java

MyProgrammingLab

4.11) Create a class named Pizza that stores information about a single pizza. It should contain the following: Private instance variables to store the size of the pizza (either small, medium, or large), the number of cheese toppings, the number of pepperoni toppings, and the number of ham toppings. Constructor(s) that set all of the instance variables. Public methods to get and set the instance variables. A public method named calcCost( ) that returns a double that is the cost of the pizza. Pizza cost is determined by: Small: $10 + $2 per topping Medium: $12 + $2 per topping Large: $14 + $2 per topping A public method named getDescription() that returns a String containing the pizza size, quantity of each topping, and the pizza cost as calculated by calcCost(). Write main method that asks for pizza size and number of toppings for each category. It should then initialize Pizza class and Print out the string from getDescription()

Sample Run

EnterthesizeofPizza:Large

EnterthenumberofCheesetoppings:2

EnterthenumberofPepperonitoppings:0

EnterthenumberofHamtoppings:1

LargePizzawith2Cheesetoppings,0Pepperonitoppings,and1Hamtoppings.

TotalPrice:20.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students explore these related Databases questions

Question

What is the relationship between humans?

Answered: 3 weeks ago

Question

What is the orientation toward time?

Answered: 3 weeks ago