Answers for "21. a. Create a class named Sandwich. Data fields include a String for the main ingredient(such as tuna), a String for bread type (such as wheat), and a double for price such as 4.99. include method to get and set values for each fields."

0

21. a. Create a class named Sandwich. Data fields include a String for the main ingredient(such as tuna), a String for bread type (such as wheat), and a double for price such as 4.99. include method to get and set values for each fields.

public class Sandwich {
    private String mainIngredient;
    private String breadType;
    private double price;
    
    public String getMainIngredient() {
        return mainIngredient;
    }

    public void setMainIngredient(String mainIngredient) {
        this.mainIngredient = mainIngredient;
    }

    public String getBreadType() {
        return breadType;
    }

    public void setBreadType(String breadType) {
        this.breadType = breadType;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

}
Posted by: Guest on April-10-2022

Code answers related to "21. a. Create a class named Sandwich. Data fields include a String for the main ingredient(such as tuna), a String for bread type (such as wheat), and a double for price such as 4.99. include method to get and set values for each fields."

Browse Popular Code Answers by Language