
create a class names pizza data fields include a String for toppings such as pepperoni and inteager for diameter in inches 12" abd a diuble ofor price such as 13.99 include methods to get and set values for each for these fields

public class Pizza{
private int size;
private String toppings;
private double price;
public Pizza(){
setSize(12);
setToppings("pepperoni");
setPrice(13.99);
}
public void setSize(int size)
{
this.size = size;
}
public void setToppings(String toppings)
{
this.toppings = toppings;
}
public void setPrice(double price)
{
this.price = price;
}
public int getSize()
{
return this.size;
}
public String getToppings()
{
return this.toppings;
}
public double getPrice()
{
return price;
}
public static void main(String []args){
Pizza p=new Pizza();
System.out.println("Size: " + p.getSize()+" inches");
System.out.println("Toppings: " + p.getToppings());
System.out.println("Price: " + p.getPrice());
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.