JAVA PROGRAMMING-LMS INTEG.MINDTAP
JAVA PROGRAMMING-LMS INTEG.MINDTAP
8th Edition
ISBN: 9781337091503
Author: FARRELL
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 4, Problem 5PE

a.

Program Plan Intro

Bread

Program Plan:

Bread.java:

  • Define the class “Bread”.
    • Declare and initialize the required variable.
    • Definition of constructor.
      • Assign the “bread” and “cal” to the “breadName” and “calories”.
      • Definition of “getBreadType()”.
        • Return the value of “breadName”.
      • Definition of method “getCaloriesPerSlice()”
        • Return the value of “calories”

BreadTest.java:

  • Define the class “BreadTest”.
    • Define the main method.
      • Create an object for bread.
      • Call the method bread.
    • Definition of method “display()”.
      • Get the type of bread and calories per slice by calling the method “getBreadType()” and “getCaloriesPerSlice()”.
      • Print the result.

b.

Program Plan Intro

SandwichFilling.java

Program Plan:

SandwichFilling.java:

  • Define the class “SandwichFilling”.
    • Declare and initialize the required variable.
    • Definition of constructor.
      • Assign the “fill” and “calories” value to the variables.
    • Definition of method “getSandwichFilling()”.
      • Return the value filling.
    • Definition of method “getCalories()”.
      • Return the value calories.

TestSandwichFilling.java:

  • Define the class “TestSandwichFilling”.
    • Define the main method.
      • Create an object for “SandwichFilling”.
      • Call the method “display()”.
    • Definition of method “display()”.
      • Get the type of sandwich filling and calories per slice by calling the method “getSandwichFilling()” and “getCalories()”.
      • Print the result.

c.

Program Plan Intro

Sandwich.java

Program Plan:

Sandwich.java:

  • Define the class “SandwichFilling”.
    • Declare and initialize the required variable.
    • Definition of constructor.
      • Assign the “Bread” and “Sandwich” value to the variables.
    • Definition of method “getBread()”.
      • Return the value filling.
    • Definition of method “getSandwich()”.
      • Return the value calories.

TestSandwichFilling.java:

  • Define the class “TestSandwich”.
    • Define the main method.
      • Create an object for “Sandwich”.
      • Call the method “display()”.
    • Definition of method “display()”.
      • Declare the variable “SLICE”.
      • Create an object for “Bread”.
      • Create an object for “SandwichFilling”.
      • Print the details of bread.
      • Print the details of “sandwichFilling”.
      • Print the details of “sandwich”

Blurred answer
Students have asked these similar questions
can you please give me: * the code (step 3) *the list file (step 5) *and answer step 6   Thank you
# Find the error# Why will the following code not print out a list of contact namesphoneBook = {'Doe, Jane' : '843-000-0000' ,'Doe, John' : '843-111-1111' ,'Smith, Adam' : '843-222-2222' ,'Jobs, Steve' : '999-333-3333' ,}for contact in phoneBook.values():print(contact)
# Find the error:# The following code creates an empty dictionary and attempts to add a record# Why will the following code not create a new dictionary entry as intended?phoneBook = {}phoneBook{'Jobs, Steve'} = '999-111-1111'
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:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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
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