this could not run correctly there is no outpot where is the problem here using
ID: 3716624 • Letter: T
Question
this could not run correctly
there is no outpot
where is the problem here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
public class Pizza
{
public String pizzaSize;
int cheeseCount;
int pepperoniCount;
int hamCount;
public Pizza()
{
this.pizzaSize = "";
this.cheeseCount = 0;
this.pepperoniCount = 0;
this.hamCount = 0;
}
public Pizza(String pizzaSize, int cheeseCount, int pepperoniCount, int hamCount)
{
this.pizzaSize = pizzaSize;
this.cheeseCount = cheeseCount;
this.pepperoniCount = pepperoniCount;
this.hamCount = hamCount;
}
public String PizzaSize()
{
return pizzaSize;
}
public void setPizzaSize(String pizzaSize)
{
this.pizzaSize = pizzaSize;
}
public int getCheeseToppings()
{
return cheeseCount;
}
public void setCheeseToppings(int cheeseCount)
{
this.cheeseCount = cheeseCount;
}
public int getPepperoniToppings()
{
return pepperoniCount;
}
public void setPepperoniToppings(int pepperoniCount)
{
this.pepperoniCount = pepperoniCount;
}
public int getNumHmaToppings()
{
return hamCount;
}
public void setNumHmaToppings(int hamCount)
{
this.hamCount = hamCount;
}
public double calcCost()
{
if (pizzaSize == "small")
{
return 10 + (cheeseCount + pepperoniCount + hamCount) * 2;
}
else if (pizzaSize == "medium")
{
return 12 + (cheeseCount + pepperoniCount + hamCount) * 2;
}
else if (pizzaSize == "large")
{
return 14 + (cheeseCount + pepperoniCount + hamCount) * 2;
}
else
{
return 0.0;
}
}
public String getDescription()
{
return "Pizza size: " + pizzaSize + " Cheese toppings: "
+ cheeseCount + " Pepperoni toppings: "
+ pepperoniCount + " Ham toppings: " + hamCount;
}
static void Main(string[] args)
{
Pizza pizza = new Pizza();
pizza.calcCost();
pizza.getDescription();
}
}
}
}
Explanation / Answer
using System;
public class Pizza
{
public String pizzaSize;
int cheeseCount;
int pepperoniCount;
int hamCount;
public Pizza()
{
this.pizzaSize = "";
this.cheeseCount = 0;
this.pepperoniCount = 0;
this.hamCount = 0;
}
public Pizza(String pizzaSize, int cheeseCount, int pepperoniCount, int hamCount)
{
this.pizzaSize = pizzaSize;
this.cheeseCount = cheeseCount;
this.pepperoniCount = pepperoniCount;
this.hamCount = hamCount;
}
public String PizzaSize()
{
return pizzaSize;
}
public void setPizzaSize(String pizzaSize)
{
this.pizzaSize = pizzaSize;
}
public int getCheeseToppings()
{
return cheeseCount;
}
public void setCheeseToppings(int cheeseCount)
{
this.cheeseCount = cheeseCount;
}
public int getPepperoniToppings()
{
return pepperoniCount;
}
public void setPepperoniToppings(int pepperoniCount)
{
this.pepperoniCount = pepperoniCount;
}
public int getNumHmaToppings()
{
return hamCount;
}
public void setNumHmaToppings(int hamCount)
{
this.hamCount = hamCount;
}
public double calcCost()
{
if (pizzaSize == "small")
{
return 10 + (cheeseCount + pepperoniCount + hamCount) * 2;
}
else if (pizzaSize == "medium")
{
return 12 + (cheeseCount + pepperoniCount + hamCount) * 2;
}
else if (pizzaSize == "large")
{
return 14 + (cheeseCount + pepperoniCount + hamCount) * 2;
}
else
{
return 0.0;
}
}
public String getDescription()
{
return "Pizza size: " + pizzaSize + " Cheese toppings: "
+ cheeseCount + " Pepperoni toppings: "
+ pepperoniCount + " Ham toppings: " + hamCount;
}
public static void Main()
{
Pizza pizza = new Pizza("large", 3, 2, 4);
Console.WriteLine(pizza.calcCost());
Console.WriteLine(pizza.getDescription());
}
}
//NOTE : You forgot to print the result of the both functions.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.