In: Computer Science
PLEASE EXPLAIN ANSWER. USING JAVA via jGRASP
i am getting an error messge
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 methods to get and set values for each of these fields. Save the class as Sandwich.java.
b. Create an application named TestSandwich that instantiates one Sandwich object and demonstrates the use of the set and get methods. Save this application as TestSandwich.java.
//Java Code
public class Sandwich {
    private String mainIngredient;/*String for the main ingredient (such as tuna)*/
    private String breadType;/*String for bread type (such as wheat)*/
    private double price;/* double for price (such as 4.99)*/
    //getters and setters
    /**
     *
     * @return main ingredient
     */
    public String getMainIngredient() {
        return mainIngredient;
    }
    /**
     * set main ingredient
     * @param mainIngredient
     */
    public void setMainIngredient(String mainIngredient) {
        this.mainIngredient = mainIngredient;
    }
    /**
     *
     * @return bread type
     */
    public String getBreadType() {
        return breadType;
    }
    /**
     * set bread type
     * @param breadType
     */
    public void setBreadType(String breadType) {
        this.breadType = breadType;
    }
    /**
     *
     * @return price
     */
    public double getPrice() {
        return price;
    }
    /**
     * set price
     * @param price
     */
    public void setPrice(double price) {
        this.price = price;
    }
}
public class TestSandwich {
    public static void main(String[] args)
    {
        // instantiates one Sandwich object
        Sandwich sandwich = new Sandwich();
        //set the main ingredient
        sandwich.setMainIngredient("Tuna");
        // set bread type
        sandwich.setBreadType("Wheat");
        //set price
        sandwich.setPrice(4.99);
        //print object info using getters
        System.out.println("Main Ingredient: "+sandwich.getMainIngredient()+", Bread Type: "+sandwich.getBreadType()+", Price: "+sandwich.getPrice());
    }
}
//Output

//If you need any help regarding this solution....... please leave a comment..... thanks