Question: Complete the following tasks: a. Design a class named Pizza. Data fields include a string field for a topping (such as pepperoni) and numeric fields

Complete the following tasks:
a. Design a class named Pizza. Data fields include a string field for a topping (such as pepperoni) and numeric fields for diameter in inches (such as 12) and price (such as 13.99). Include methods to get and set values for each of these fields. Create the class diagram and write the pseudocode that defines the class.
b. Design an application that declares two Pizza objects and sets and displays their values.
c. Design an application that declares an array of 10 Pizza objects. Prompt the user for data for each Pizza, then display all the values.
d. Design an application that declares an array of 10 Pizza objects. Prompt the user for a topping and diameter for each Pizza, and pass each object to a method that computes the price and returns the complete Pizza object to the main program. Then display all the Pizza values. A 12−inch pizza is $13.99, a 14−inch pizza is $16.99, and a 15−inch pizza is $19.99. Any other entered size is invalid and should cause the price to be set to 0.

Step by Step Solution

3.47 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Explanation Class Pizza Data Fields topping string diameter numeric price numeric Methods setTopping... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Logic & Design Questions!