Java Programming (MindTap Course List)
Java Programming (MindTap Course List)
8th Edition
ISBN: 9781285856919
Author: Joyce Farrell
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 3, Problem 11PE

Explanation of Solution

a.

Program code:

Sandwich.java

//create a class Sandwitch

public class Sandwich

{

//create string variables

private String ingredient, breadType;

//create double variable

private double price;

//define a constructor

public Sandwich()

{

}

//define a method getIngredient()

public String getIngredient()

{

//return the ingredient

return ingredient;

}

//define a method setIngredient()

public void setIngredient(String ingredient)

{

//set value of the variable ingredient

this.ingredient = ingredient;

}

//define a method getBreadType()

public String getBreadType()

{

//return the breadType

return breadType;

}

//define a method setBreadType()

public void setBreadType(String breadType)

{

//set value of the variable breadType

this.breadType = breadType;

}

//define a method getPrice()

public double getPrice()

{

//return the price

return price;

}

//define a method setPrice()

public void setPrice(double price)

{

//set value of the variable price

this.price = price;

}

}

Explanation:

The above snippet of code is used create a class “Sandwich”. The class contain different static methods for store the details of sandwich. In the code,

  • Define a class “Sandwich”
    • Define the constructor “Sandwich()” method.
    • Define the “getIngredient()” method.
      • Return the value of the variable “ingredient”.
    • Define the “setIngredient()” method.
      • Set the value of the variable “ingredient”.
    • Define the “getBreadType()” method.
      • Return the value of the variable “breadType”.
    • Define the “setBreadType ()” method...

Blurred answer
Students have asked these similar questions
Write a program that simulates a Magic 8 Ball, which is a fortune-telling toy that displays a random response to a yes or no question. In the student sample programs for this book, you will find a text file named 8_ball_responses.txt. The file contains 12 responses, such as “I don’t think so”, “Yes, of course!”, “I’m not sure”, and so forth. The program should read the responses from the file into a list. It should prompt the user to ask a question, then display one of the responses, randomly selected from the list. The program should repeat until the user is ready to quit. Contents of 8_ball_responses.txt:  Yes, of course! Without a doubt, yes. You can count on it. For sure! Ask me later. I'm not sure. I can't tell you right now. I'll tell you after my nap. No way! I don't think so. Without a doubt, no. The answer is clearly NO. (You can access the Computer Science Portal at www.pearsonhighered.com/gaddis.)
Start with the initial angles within the integration and just integrate them without mapping them to specific quadrants. Use python and radians
How does encryption prevent a hacker from getting your data
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY