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);
}
}
This is my code above any help would be appreciated. Thank you so much guys. Java is a general-purpose computer-programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
The name of the method and class should not be same. You are trying to initialise instance variable using constructor. But the syntax for the constructor is not correct and also it implicitly returns reference to the object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.