Answer to Question #262408 in Java | JSP | JSF for Laiba Shahid

Question #262408

1. A parameterized constructor taking 4 arguments for bread slices, cheese slices, meat patty number and tomato slices. The values of the rest of the variables will be initialized by default to true 2. Another parameterized constructor that takes argument for each of these variables and initializes them accordingly 3. Another parameterized constructor that takes argument for each of these variables and initializes them accordingly 4. Provide setters for mustard, ketchup, iceberg and gilled 5. Provide getters for each of these variables 6. Provide a method calculatePrice() that calculates and returns the price of this sandwich according to the rates given in the above table.


1
Expert's answer
2021-11-07T10:13:25-0500
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		
	}
}


class Food{
    private int bread_slices;
    private int cheese_slices;
    private int meat_patty_number;
    private int tomato_slices;
    private int mustard;
    private int ketchup;
    private int iceberg;
    private int gilled;
    
    public Food(int b,int c,int m,int t){
        bread_slices=b;
        cheese_slices=c;
        meat_patty_number=m;
        tomato_slices=t;
    }
    public void setMustard(int m){
        mustard=m;
    }
    public void setKetchup(int k){
        ketchup=k;
    }
    public void setIceberg(int i){
        iceberg=i;
    }
    public void setGilled(int g){
        gilled=g;
    }
    
    public int getMustard(){
        return mustard;
    }
    public int getKetchup(){
        return ketchup;
    }
    public int getIcberg(){
        return iceberg;
    }
    public int getGilled(){
        return gilled;
    }
    public int calculatePrice(){
        Scanner in=new Scanner(System.in);
        int price;
        System.out.print("Enter total price: ");
        price=in.nextInt();
        return price;
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS