I cannot understand whats the problem in my code? Please Help! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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); } }

3rd Mar 2019, 7:52 PM
Mohammed Amir Khan
Mohammed Amir Khan - avatar
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)); } }
5th Mar 2019, 1:18 AM
M_N
+ 1
Julien Quentin is right
3rd Mar 2019, 9:14 PM
Ore
Ore - avatar