Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5, Problem 7E
Consider a class MotorBoat that represents motorboats. A motorboat has attributes for
- The capacity of the fuel tank
- The amount of fuel in the tank
- The maximum speed of the boat
- The current speed of the boat
- The efficiency of the boat’s motor
- The distance traveled
The class has methods to
- Change the speed of the boat
- Operate the boat for an amount of time at the current speed
- Refuel the boat with some amount of fuel
- Return the amount of fuel in the tank
- Return the distance traveled so far
If the boat has efficiency e, the amount of fuel used when traveling at a speed s for time t is e × s2 × t. The distance traveled in that time is s × t.
- a. Write a method heading for each method.
- b. Write preconditions and postconditions for each method.
- c. Write some Java statements that test the class.
- d. Implement the class.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Activity: Interaction Models
Consider the university system. Departments offer courses. Professors teach courses.
Students can declare majors and are admitted to university departments if they meet
minimum requirements. Students and professors have schedules based on courses they
take/teach. Courses have rosters, scheduled times, and instructors. Courses may get
full. Students can request to sign up for courses, and if the course is not full and they
meet pre-requisites, the course is added to their schedule and the course will have
them as a student in that course. Students can also drop courses. Students should be
informed of the consequences such as change of status from full-time to part-time,
loss of scholarships, and delays in graduation.
Perform the following:
1.
Create a use-case diagram for this university. Make your use-case diagram as
complete as you can.
2. Pick two use cases from your use case diagram, CourseAdd and CourseDrop, and
describe these use cases in the standard…
Identify classes and draw object diagram for ATM Machine Software Application
Considering requirements:
1. Withdraw money using card and pin
2. Check balance
3. Fast cash withdrawal
4. Card less withdrawal
5. Pin change
Draw a UML class diagram for "clothing and other item donations"
people can list the items available to donate. And people in need can request what items they need.
please help, thank you.
Chapter 5 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 5.1 - Consider the program in Listing 5.4 . Suppose you...Ch. 5.1 - Prob. 2STQCh. 5.1 - Prob. 3STQCh. 5.1 - Suppose every species in the world has a peculiar...Ch. 5.1 - Revise the definition of the method writeOutput in...Ch. 5.1 - Revise the definition of the method readInput in...Ch. 5.1 - Revise the definition of the method...Ch. 5.1 - What is the meaning of (int) that appears in the...Ch. 5.1 - Prob. 9STQCh. 5.1 - Define a method called getDensity that could be...
Ch. 5.1 - Define a method called changePopulation that could...Ch. 5.1 - Define a method called changePopulation that could...Ch. 5.2 - In Listing 5.12, we set the data for the object...Ch. 5.2 - Give preconditions and postconditions for the...Ch. 5.2 - What is an accessor method? What is a mutator...Ch. 5.2 - Give the complete definition of a class called...Ch. 5.2 - Prob. 17STQCh. 5.2 - In the definition of the method in Listing 5.15,...Ch. 5.2 - What is a well-encapsulated class definition?Ch. 5.2 - When should an instance variable in a class...Ch. 5.2 - Prob. 21STQCh. 5.2 - In a class definition, is anything private ever...Ch. 5.2 - In a class definition, is the body of any method...Ch. 5.3 - What is a reference type? Are class types...Ch. 5.3 - When comparing two quantities of a class type to...Ch. 5.3 - Prob. 26STQCh. 5.3 - Write a method definition for a method called...Ch. 5.3 - Given the class Species as defined in Listing...Ch. 5.3 - After correcting the program in the previous...Ch. 5.3 - What is the biggest difference between a parameter...Ch. 5.3 - Prob. 31STQCh. 5.3 - Write an equals method for the class Person...Ch. 5.4 - Rewrite the method drawFaceSansMouth in Listing...Ch. 5 - Design a class to represent a credit card. Think...Ch. 5 - Repeat Exercise 1 for a credit card account...Ch. 5 - Repeat Exercise 1 for a coin instead of a credit...Ch. 5 - Repeat Exercise 1 for a collection of coins...Ch. 5 - Consider a Java class that you could use to get an...Ch. 5 - Consider a class that keeps track of the sales of...Ch. 5 - Consider a class MotorBoat that represents...Ch. 5 - Prob. 8ECh. 5 - Prob. 9ECh. 5 - Prob. 10ECh. 5 - Write a program to answer questions like the...Ch. 5 - Define a class called Counter. An object of this...Ch. 5 - Prob. 3PCh. 5 - Define a Trivia class that contains information...Ch. 5 - Define a Beer class that contains the following...Ch. 5 - Write a grading program for an instructor whose...Ch. 5 - Add methods to the Person class from Self-Test...Ch. 5 - Create a class that represents a grade...Ch. 5 - Write a program that uses the Purchase class in...Ch. 5 - Write a program to answer questions like the...Ch. 5 - Consider a class that could be used to play a game...Ch. 5 - Consider a class BasketballGame that represents...Ch. 5 - Consider a class ConcertPromoter that records the...Ch. 5 - Prob. 9PPCh. 5 - Consider a class Movie that contains information...Ch. 5 - Repeat Programming Project 18 from Chapter 4, but...Ch. 5 - Prob. 12PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain why SQL is called a set-oriented language.
Modern Database Management
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
How is a constructor named?
Starting Out with Java: Early Objects (6th Edition)
(Displaying a Square of Asterisks) Write a method squareOfAsterisks that displays a solid square (the same numb...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
What characteristic of Rubys arithmetic operators makes them unique among those of other languages?
Concepts Of Programming Languages
Redesign the logic for segment a in the Applied Logic to include the letter F in the display.
Digital Fundamentals (11th Edition)
Knowledge Booster
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
- draw the UML diagramarrow_forwardComputer Science The term “knowledge” is defined in the dictionary (Oxford Learner’s Dictionaries) as the information, understanding, and skills that a person gains through education or experience. So, it is expected that only human-beings can possess and use knowledge. However, with machine learning and deep learning, it now seems that “machine” can also possess and use knowledge. For example, Google’s AlphaGO won three-match series against the world’s best Go players. Can “machine” possess and use knowledge? What do you think? Please provide details and examples to support your opinions.arrow_forwardIf a child has red hair, they inherited a certain From their parentsarrow_forward
- Interacting Marketing Read the following scenario carefully and based on, answer the below questions: Scenario: In this scenario [Design phase], the producers (producer-Name, producer-Address, and trade-Made) are marketing their products (Product-Name, offers- No) to consumers. This scenario is centered around “Making a sale”. The object traders (trade-No, Buyer, producer, and product) provide the services needed by consumers and producers. The object products keeps information about the items traded in the system. Each products include any number of PRODUCT-OFFERS (producer, and offer-price, sales), each producer giving QTY-AVAILABLE and asking –price. It also keeps a record of all the offers of items for sale by procedures and all the sales (buyer-Name, producer, product, price) made by the system. The object “traders” is like an agent that provides all the services needed by the buyers (buyer-Name, purchase) to arrange a sale. The buyer states the requested product…arrow_forwardTo fully define a variable one needs to mention not only its type but also its other properties. In other words, not only do all variables have a data type, they also contain other properties. Explain the concept that will help us to describe the properties of any variable.arrow_forwardCourse: System Analysis And Design , ITMA 411 State refers to an object’s current status. A state transition diagram shows how an object changes from one state to another, depending on events that affect the object. All possible states must be documented in the state transition diagram.In a state transition diagram, the states appear as rounded rectangles with thestate names inside. The initial state represented as a small circle, and it is the point where the object first interacts with the system. Lines used to show direction and describe the action or event that causes a transition from one state to another. The final state represented as a circle with a hollow border.In this assignment you are requested to create State Transition Diagram for the student registration system. Kindly Use Lucid Chartarrow_forward
- Create your own UML diagram — similar to the above UML diagram — for a Pet class that meets thespecification below.1. Create the fields indicated below. Use these names exactly as given for your fields. Define them inexactly this order.• name — The name of the pet, e.g., “Rufus”, “Mittens”, “Smelly”, etc.• animal — The type of pet, e.g., “dog”, “cat”, “asparagus”, etc.• age — The (integer) number of years the pet has been alive, e.g., 1, 2, 3, etc.2. Create a mutator for each of the above in the order listed. Use the standard Java naming conventionfor mutators.3. Create an accessor for each of the above in the order listed. Use the standard Java naming conventionfor accessors.Example: Suppose you are taking the question for the example Car UML above instead of your Pet UML.Don’t enter any spaces at all.When the question asks: Enter line 1:You would enter: CarWhen the question asks: Enter line 2:You would enter: -make:StringWhen the question asks: Enter line 3:You would enter:…arrow_forwardCreate your own UML diagram — similar to the below UML diagram — for a Pet class that meets thespecification below.1. Create the fields indicated below. Use these names exactly as given for your fields. Define them inexactly this order.• name — The name of the pet, e.g., “Rufus”, “Mittens”, “Smelly”, etc.• animal — The type of pet, e.g., “dog”, “cat”, “asparagus”, etc.• age — The (integer) number of years the pet has been alive, e.g., 1, 2, 3, etc.2. Create a mutator for each of the above in the order listed. Use the standard Java naming conventionfor mutators.3. Create an accessor for each of the above in the order listed. Use the standard Java naming conventionfor accessorsarrow_forwardCourse: Database Systems: Design and Application Web Shop scenario: A supplier (Supp-#) processes many purchase orders (PO-#) and sells a number of products (Prod-#). A product is sold by only one supplier. Each of the purchase orders that a supplier may process includes several products. The relationship between order and product is defined as "Line Item". A customer (Cust-#) may place one or more purchase orders. A purchase order may be placed by only one customer. Assignment requirements: Answer the following questions using above scenario: Identify the entities and attributes that required to draw the ER diagram. Integrate the entities with appropriate relationship and design the unified ER model.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks ColePrinciples of Information Systems (MindTap Course...Computer ScienceISBN:9781285867168Author:Ralph Stair, George ReynoldsPublisher:Cengage Learning
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License