Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. (Pizza) (30 points) Create a C# static function named PizzaCost that calculat

ID: 3715082 • Letter: 3

Question

3. (Pizza) (30 points) Create a C# static function named PizzaCost that calculates the cost of a pizza. It has 4 parameters representing 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. It returns a double that is the cost of a pizza. The cost of a pizza is determined by:

? Small: $10 + $2 per topping

? Medium: $12 + $2 per topping

? Large: $14 + $2 per topping

For example, a large pizza with one cheese (1x$2), one pepperoni (1x$2) and two ham toppings (2x$2) should cost a total of $22. (i.e. $14+1x$2+1x$2+2x$2=$22) Create a C# static function named PizzaDescription that print the information of a pizza. It has 5 parameters representing the size of the pizza (either small, medium, or large), the number of cheese toppings, the number of pepperoni toppings, the number of ham toppings, and the total cost of a pizza. It prints the information of a pizza, including its size, the number and kind of each topping, and the cost. In the main method, call these two functions sequentially (i.e., call PizzaCost and then call PizzaDescription)

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Main_method
{
   class Pizza
    {

        int cheeseToppings;        
        int pepperoniToppings;

        int hamToppings;

        string size;
        int price;

        int totalPrice;

       

       public void pizzaCost(){

          Console.Write(" Size of pizza (1.small or 2.medium or 3.large)(press the number): ");

            Int num = int.Parse(Console.ReadLine());

          If(num == 1){

size = “Small”;

price = 10;

}else if(num ==2){

size = “Medium”;

price = 12;

}else if(num == 3)

size = “Large”;

price = 14;

}

            Console.Write(" No of Cheese Toppings: ");

            cheeseToppings = int.Parse(Console.ReadLine());

          Console.Write(" No of Pepperoni Toppings: ");

            pepperoniToppings = int.Parse(Console.ReadLine());

          Console.Write(" No of Ham Toppings: ");

            hamToppings = int.Parse(Console.ReadLine());

          totalPrice = price + cheeseToppings * 2 + pepperoniToppings * 2 + hamToppings * 2;
         
    }

   public void pizzaDescription(){

      Console.Write(" Size of pizza : " + size);

            Console.Write(" No of Cheese Toppings: " + cheeseToppings);

          Console.Write(" No of Pepperoni Toppings: " + pepperoniToppings);

          Console.Write(" No of Ham Toppings: " + hamToppings);

          Console.Write(" Pizza Cost: " + totalPrice);

    }

    
}

class Program
    {
        static void Main(string[] args)
        {
            Pizza pizza = new Pizza();
            pizza.pizzaCost();                       //invoke for accep the details and calculate cost
            pizza.pizzaDescription();            //print the total details
            Console.ReadLine();


        }

     }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote