EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 4, Problem 3PE
Program Plan Intro
a.
Construct the default constructor
Filename: “FitnessTracker.java”
- Import the header files in the program.
- Define the “FitnessTracker” class.
- Declare the required variables.
- Define of constructor
- Set the default values
- Get the local date
- Define “getActivity” method
- Return the activity
- Define “getMinutes” method
- Return the minutes.
- Define “getDate” method
- Return the date.
Filename: “TestFitnessTracker.java”
- Define the “TestFitnessTracker” class.
- Define the main method.
- Create an object for “FitnessTracker” class.
- Display the result for exercise (a).
- Create an object for “LocalDate” class
- Define the main method.
Program Plan Intro
b.
Construct the parameterized constructor
Program plan:
Filename: “FitnessTracker.java”
- Import the header files in the program.
- Define the “FitnessTracker” class.
- Declare the required variables.
- Define of constructor
- Set the default values
- Get the local date
- Define of parameterized constructor
- Set the values.
- Define “getActivity” method
- Return the activity
- Define “getMinutes” method
- Return the minutes.
- Define “getDate” method
- Return the date.
Filename: “TestFitnessTracker.java”
- Define the “TestFitnessTracker” class.
- Define the main method.
- Create an object for “FitnessTracker” class.
- Display the result for exercise (a).
- Create an object for “LocalDate” class
- Create an object for “FitnessTracker” class.
- Display the result for exercise (b).
- Define the main method.
Program Plan Intro
c.
Call the three parameter constructor
Program plan:
Filename: “FitnessTracker2.java”
- Import the header files in the program.
- Define the “FitnessTracker2” class.
- Declare the required variables.
- Define of constructor
- Set the default values using “this” method.
- Define of parameterized constructor
- Set the values.
- Define “getActivity” method
- Return the activity
- Define “getMinutes” method
- Return the minutes.
- Define “getDate” method
- Return the date.
Filename: “TestFitnessTracker2.java”
- Define the “TestFitnessTracker2” class.
- Define the main method.
- Create an object for “FitnessTracker2” class.
- Display the result for exercise (c).
- Create an object for “LocalDate” class
- Create an object for “FitnessTracker2” class.
- Display the result for exercise (b).
- Define the main method.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
a - Create a FitnessTracker class that includes data fields for a fitness activity, the number of minutes spent participating, and the date. The class includes methods to get each field. In addition, create a default constructor that automatically sets the activity to running, the minutes to 0, and the date to January 1 of the current year. Save the file as FitnessTracker.java. Create an application that demonstrates each method works correctly, and save it as TestFitnessTracker.java.
b - Create an additional overloaded constructor for the FitnessTracker class you created in Exercise 3a. This constructor receives parameters for each of the data fields and assigns them appropriately. Add any needed statements to the TestFitnessTracker application to ensure that the overloaded constructor works correctly, save it, and then test it.
c - Modify the FitnessTracker class so that the default constructor calls the three-parameter constructor. Save the class as FitnessTracker2.java. Create an…
Instructions:
IMPORTANT: This is a continuation of the previous part of the project and assumes that you are starting with code that fulfills all requirements from that part of the project.
Modify the your code from the previous part of the project to make it modular.
In addition to the main method, your code must include the following static methods:
Method 1 - displayTitle
A method that creates a String object in memory to hold the text “Computer Hardware Graphics Quality Recommendation Tool” and displays it
Method 2 – getResolutionString
A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution. The method should return the appropriate String representation of the monitor resolution. For example, if the method is passed an integer value of 1, it should return a String with a value of “1280 x 720”. (See Step 4 of Project 1)
Method 3 – getMultiplierValue
A method that accepts an integer value (1, 2, 3, or 4) that denotes the monitor resolution and…
Please help me solve this with java..I posted it many times and got rejected I don't ?
Game class instructions:• Game class has three attributes: points (which represent the number of points awarded when winning the game), status (false if the game has not been played and true if the game has been played), and description (which is a text description of the game). Note that description attribute is a read-only variable. • In the constructor, initialize points to zero, status to false, and description to the given parameter.• isPlayed method returns true if the game has been played, and false otherwise.• getPoints is a getter method for points attribute.• play method is an abstract method.• Override toString method to return the game description.• Override equals method so that two games are the same if their descriptions are the same. :instructions class ) HangMan• HangMan is a game in which a player tries to guess a word based on a given hint. For example, if the given hint is…
Chapter 4 Solutions
EBK JAVA PROGRAMMING
Ch. 4 - Prob. 1RQCh. 4 - Prob. 2RQCh. 4 - Prob. 3RQCh. 4 - Prob. 4RQCh. 4 - Prob. 5RQCh. 4 - Prob. 6RQCh. 4 - Prob. 7RQCh. 4 - Prob. 8RQCh. 4 - Prob. 9RQCh. 4 - Prob. 10RQ
Ch. 4 - Prob. 11RQCh. 4 - Prob. 12RQCh. 4 - Prob. 13RQCh. 4 - Prob. 14RQCh. 4 - Prob. 15RQCh. 4 - Prob. 16RQCh. 4 - Prob. 17RQCh. 4 - Prob. 18RQCh. 4 - Prob. 19RQCh. 4 - Prob. 20RQCh. 4 - Prob. 1PECh. 4 - Prob. 2PECh. 4 - Prob. 3PECh. 4 - Prob. 4PECh. 4 - Prob. 5PECh. 4 - Prob. 6PECh. 4 - Prob. 7PECh. 4 - Prob. 8PECh. 4 - Prob. 9PECh. 4 - Prob. 10PECh. 4 - Prob. 11PECh. 4 - Prob. 1GZCh. 4 - Prob. 2GZ
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
- Create a class for Subject containing the Name of the subject and score of the subject. There should be following methods: set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9” getScore: it will return the value of score. greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score. Create a class “Main” having main method to perform following tasks. Create two objects of Subject class having value “Math, 99.9”…arrow_forwardCreate a class for Subject containing the Name of the subject and score of the subject. There should be following methods: set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9” getScore: it will return the value of score. greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score. note....... solve with javaarrow_forwardIn Java create the following: Design a Ship class that the following members: A field for the name of the ship (a string) A field for the year that the ship was built (a string) A constructor and appropriate accessors and mutators A toString method that displays the ship’s name and the year it was built Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers (an int) A constructor and appropriate accessors and mutators A toString method that overrides the toString method in the base class The CruiseShip class’s toString method should display only the ship’s name and the maximum number of passengers Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int) A constructor and appropriate accessors and mutators A toString method that overrides the toString method in the base class…arrow_forward
- If you have a class that you can not modify its code, and you want to add features to this class, in this case which pattern to use Select one: a. Factory Method b. Decorator c. Observer d. Abstract Factoryarrow_forwardDirections This exercise will provide you with the opportunity to utilize NetBeans to create an application that calculates interest. End Result: Console Create the Scanner object. Get the loan information from the end user by using the System class. Calculate the interest amount by using the BigDecimal class to make sure that all calculations are accurate. Format the interest rate, interest amount and loan amount and interest by using the NumberFormat abstract base class. It should round the interest that’s calculated to two decimal places, rounding up if the third decimal place is five or greater. The value for the formatted interest rate should allow for up to 3 decimal places. Display the results by using the System class. Assume that the user will enter valid double values for the loan amount and interest rate. The application should continue only if the user enters “y” or “Y” to continue.arrow_forwardInstructions This assignment must follow directions exactly. Create a class Lab02 with a main method, and put all of the following code into the main method: Print the prompt shown below and ask the user for the number of exemptions. The number of exemptions is an integer. Print the prompt shown below and ask the user for their gross salary. The gross salary represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for their interest income. The interest income represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for their capital gains income. The capital gains represents dollars, which can be entered with or without decimal points. Print the prompt shown below and ask the user for the amount of charitable contributions. The charitable contributions represents dollars, which can be entered with or without decimal points. Perform the calculation of…arrow_forward
- Assignment using Methods For this exercise, you need to complete all the questions in a single project. You will invoke the methods from your main. Questions 1-6 is due at the end of your next class. Write a method with the following specifications:name: DisplayMenuarguments: nonereturn value: nonetasks: display the following menu choice on the screenCalculation Menu3) Calculate Sum 4) Calculate Sum of Squares5) Calculate Sum of Cubes0) To ExitEnter the number that corresponds to your choice: You may beautify the output to your own likings. You don’t have to implement the functionalities of the various menu choices at this stageCall this method from your main. Modify your main so that the above method is call repeatedly. The program will terminate when the user enters 0. Any other choice should produce an error message. Because you will not be doing any arithmetic you may accept the user response either as an int, or a char or a string. Write a method with the following…arrow_forwardTask 2 Create a class called RunDepartment which contains the main () method. The main must do the following: Create an object of type Department Using the object do the following: Calculate and Display Average Sales per Department. Calculate and Display Average Sales per Month Determine the Month with the Highest Sales per Department Determine the name of the department with the highest sales per month (in java form)arrow_forward__eq__(self, other): Method that returns True if self and other are considered the same Flight: if the origin and destination are the same for both Flights. Make sure that if “other” variable is not a Flight object, this means False should be returned. getFlightNumber(self): Getter that returns the Flight number getStart(self): Getter that returns the Plane Start getgoingTo(self): Getter that returns the Plane destination isDomesticFlight(self): Method that returns True if the flight is domestic, EX within a country (the Start and goingTo are in the same country); returns False if the flight is international (the Start and goingTo are in different countries) setStart(self, origin): Setter that sets (updates) the Plane Start setgoingTo(self, destination): Setter that sets (updates) the Plane GoingToarrow_forward
- Python Programming Questions (OOP): Write a class named “Bicycle” that has the following instance variables: gear, speed and brakes. This class will as well have the following methods: changeGearUp, changeGearDown, speedup, speedDown, applyBrakes, and printStates. The printStates method can print all of the current attributes of the bike object and brakes can be a Boolean type. Create an object named bike and test some of your methods/code that you have written with some output delivered to the user.arrow_forwardjavacoding please thank you!arrow_forwardA. Food Class1. The food class is defined by the three following properties: name of the item,amount of calories and the weight usually measured in grams.2. Create a constructor that takes as arguments the name, weight and amountof calories. Initialize the variable accordingly.3. You will need to retrieve the amount of calories later on. Add the necessarymethod.4. A toString method that returns the name of the item and its weight.Sample:100 grams of riceB. Meal Class1. The meal class is defined by two properties:a. Nameb. An ArrayList of Food objects that represents the food items of that specificmeal2. Create a constructor that takes as argument the name of the meal. Initializethe variables accordingly.3. Add the following methods to your class:a. addFood method that takes as argument a Food object and has noreturned value. The method adds a Food item to the ArrayList of foods. 5b. removeFood method that takes as argument a Food object and hasno returned value. The method removes the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
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