Question
C#
Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has member variables to track the type of pizza being order (either deep dish, hand tossed, or pan) along with the size (small, medium or large), type of toppings (pepperoni, cheese etc.) and the number of toppings. Create accessors for each property (ex.: type, size, type of toppings, and number of toppings). Implementation class should have a CalculateOrderPayment method to compute the total cost of the pizza order and return it as a double according to the rules: Small pizza- S10+ $2 per topping Medium pizza S14 +$2 per topping Large pizza = $17 + $2 per topping Also a PrintReceipt method to display the order information with the total amount to pay. Write a OrderPizzaTest class to demon constructor (example: if we use the given default values for the example below the total amount to pay is $23 OrderPizza myPizzaOrder new OrderPizzadeep dish,large, cheese, 3); ). Lastly, prompt the user to enter a new order with different values (hint: use the Console.ReadLine method to obtain user input) and redisplay the output with the new information strate that your program is working. IMPORTANT: remember to initialize the /CLASS IMPLEMENTATION BEGINS HERE public class OrderPizza
0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System.IO;

using System;

public class OrderPizza

{

  

string type;

string size;

string typetoppings;

int num_toppings;

public OrderPizza()

{

type="";

size="";

typetoppings="";

num_toppings=0;

  

}

public OrderPizza(string P, string s, string top, int num)

{

type=P;

size=s;

typetoppings=top;

num_toppings=num;

}

public void inputvalues()

{

Console.WriteLine("Enter Type of Pizza (Deep Dished, hand Tossed or pan");

type = Console.ReadLine();

Console.WriteLine("Enter Size of Pizza (Large, Medium or Small");

size = Console.ReadLine();

Console.WriteLine("Enter Type of Toppings (Pepperoni or cheese");

typetoppings = Console.ReadLine();

Console.WriteLine("Enter Number of toppings");

num_toppings = Convert.ToInt32(Console.ReadLine());

}

public double CalculateOrderPayment()

{

if(size=="small")

return 10+2*num_toppings;

else if(size=="medium")

return 14+2*num_toppings;

else

return 17+2*num_toppings;

}

public void PrintReceipt()

{

Console.WriteLine("Pizza type :: " + type);

Console.WriteLine("Size :: " + size);

Console.WriteLine("Topping :: "+typetoppings);

Console.WriteLine("Number of Toppings :: "+num_toppings);

Console.WriteLine("Total Amount payable is :: "+ CalculateOrderPayment());

}

}

class Program

{

static void Main()

{

OrderPizza O=new OrderPizza("Deep Dish","large", "cheeze", 3);

O.PrintReceipt();

OrderPizza P=new OrderPizza();

P.inputvalues();

P.PrintReceipt();

}

}

Output

Add a comment
Know the answer?
Add Answer to:
C# Programming Exercise and Bonus Exercise (Next Page) 1) Define a class called OrderPizza that has...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • USE!! PYTHON!!! Programming:   Pizza 1. Write a Pizza class to that this client code works. Please...

    USE!! PYTHON!!! Programming:   Pizza 1. Write a Pizza class to that this client code works. Please note that it is ok if the toppings are listed in a different order. >>> pie = Pizza() >>> pie Pizza('M',set()) >>> pie.setSize('L') >>> pie.getSize() 'L' >>>pie.addTopping('pepperoni') >>>pie.addTopping('anchovies') >>>pie.addTopping('mushrooms') >>> pie Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'}) >>>pie.addTopping('pepperoni') >>> pie Pizza('L',{'anchovies', 'mushrooms', 'pepperoni'}) >>>pie.removeTopping('anchovies') >>> pie Pizza('L',{'mushrooms', 'pepperoni'}) >>> pie.price() 16.65 >>> pie2 = Pizza('L',{'mushrooms','pepperoni'}) >>> pie2 Pizza('L',{'mushrooms', 'pepperoni'}) >>> pie==pie2 True The Pizza class should have...

  • Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php...

    Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php script, create an associative array named $order that stores the following values: - the number of cheese toppings; - the number of pepperoni toppings; - the number of ham toppings; - the size of the ordered pizza; - the number of the ordered pizza; - the total cost of the order; - the discount rate; - the total cost after the discount. 2) the...

  • Create an order entry screen program in C# to give a total for an individual pizza...

    Create an order entry screen program in C# to give a total for an individual pizza order. The Pizza order should have radio buttons for small $7, medium $9, and large $12 choices for the pizza. There should be a checkbox for drink (where a drink is $2 added if it is checked and nothing added if it is not checked. Include a textbox for the customer’s name. Have a button to calculate the subtotal (pizza choice and whether there...

  • Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a...

    Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a and task#2b the things that I am missing I'm using java domain class public class Pizza { private String pizzaCustomerName; private int pizzaSize; // 10, 12, 14, or 16 inches in diameter private char handThinDeep; // 'H' or 'T' or 'D' for hand tossed, thin crust, or deep dish, respecitively private boolean cheeseTopping; private boolean pepperoniTopping; private boolean sausageTopping; private boolean onionTopping; private boolean...

  • Take the Pizza class from assignment # 1 and modify it in the following way: -...

    Take the Pizza class from assignment # 1 and modify it in the following way: - Rename it to DeluxePizza. - Add a stuffedWithCheese (boolean) attribute to the class. - Add a veggie Topping (integer) attribute to the class. This attribute keeps track of the number of vegetables toppings excluding mushrooms. Add a static attribute numberOfPizzas (integer) which will keep track of the number of DeluxePizza objects created Update the existing non-default constructor such that it increments the numberOfPizzas by...

  • Using Java, I created 3 files, Pizza,PizzaOrder, and PizzaOrder_Demo that I attached down below. But I...

    Using Java, I created 3 files, Pizza,PizzaOrder, and PizzaOrder_Demo that I attached down below. But I cannot compile it. Could you please point out the error.The question is that This programming project extends Q1. Create a PizzaOrder class that allows up to three pizzas to be saved in an order. Each pizza saved should be a Pizza object as described in Q1. In addition to appropriate instance variables and constructors, add the following methods: public void setNumPizzas(int numPizzas)—sets the number...

  • Hello, please help me to answer my assignment, i highly appreciate your effort, kindly explain it...

    Hello, please help me to answer my assignment, i highly appreciate your effort, kindly explain it clearly. Kindly put your codes in (NOTEPAD). Thank you very much. Write a VB application that will facilitate a pizza order. 1.The user interface should have a form containing all components pertaining to pizza order presented in either option buttons or check boxes. 2.Controls must also be grouped in frames according to size, toppings, or crust type. 3.The summary of order must be presented...

  • Transform the following to first normal form (1nf) and second normal form (2nf) Customer Address Name...

    Transform the following to first normal form (1nf) and second normal form (2nf) Customer Address Name Cell 1551 E Main Street Corrie 1511551 22 N 2nd Place Jenny 8675309 1551 E Main Street Joseph 5155115 4848 W 48th Terrace Stephen 8884444 342 S Spring Way Vikki 3333342 FDs: { ???? } → { ???????, ?h???_?????? }Key: ???? Driver Car_Number Name Make Model 1 Bill Honda Civic 2 Charlie Ford Escort 3 Linda Ford Taurus 4 Nathan Subaru Outback FDs: {...

  • 3.1 - In this exercise, you will see how to offer a user a selection among...

    3.1 - In this exercise, you will see how to offer a user a selection among multiple choices. You can place all choices into a combo box using the following code: /** File HelloViewer.java */ import javax.swing.JFrame; public class HelloViewer { public static void main(String[] args) { JFrame frame = new HelloFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("HelloViewer"); frame.setVisible(true); } } ---------------------------- /** File HelloFrame.java */ import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.BorderLayout; import java.awt.Font; public class HelloFrame extends JFrame { private String message; private...

  • Exercise #3: Create a class to represent a dog. Name the class “Dog”. It will contain...

    Exercise #3: Create a class to represent a dog. Name the class “Dog”. It will contain three (3) class attributes, its bark, size, and cuteness. The bark will be the sound of the dog’s bark, as in “woof!”. Its size will be how tall the dog is from the ground, and that number should always be between 6 and 44 inches. The cuteness is a string describing how cute the dog is, based on this scale: “ugliest dog ever!” “pretty...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT