0
I cannot understand whats the problem in my code? Please Help!
class pizza { public int pizza (int price, int discount) { int total = 0; total = price - discount; return total; } } public class MyClass { public static void main(String[] args) { int itemNum; int price; String pizName; boolean extraCheese; itemNum = 1101; pizName = "Pepperoni"; extraCheese = false; System.out.println ("Your order a" +pizName+ "pizza will be served shortly."); pizza pepperoni = new pizza (50, 10); System.out.println("Your payment without discount is:" + pepperoni.price); } }
2 Answers
+ 2
class Pizza {
public int pizzaPrice(int price, int discount){
return price - discount;
}
}
public class MyClass {
public static void main(String[] args) {
int itemNum = 1101;
int price;
String pizName = "Pepperoni";
boolean extraCheese = false;
System.out.println ("Your order a " + pizName + ". Pizza will be served shortly.");
Pizza pepperoni = new Pizza ();
System.out.println("Your payment without discount is :" + pepperoni.pizzaPrice(50, 10));
}
}
+ 1
Julien Quentin is right