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
Create a class named Checkup with fields that hold a patient number, two blood pressure figures (systolic and diastolic), and two cholesterol figures (LDL and HDL). Include methods to get and set each of the fields. Include a method named computeRatio() that divides LDL cholesterol by HDL cholesterol and displays the result. Include an additional method named explainRatio() that explains that HDL is known as “good cholesterol” and that a ratio of 3.5 or lower is considered optimum. Save the class as CheckupType.cpp.
Create a tester program named TestCheckup whose main() method declares four Checkup objects. Call a getData() method four times. Within the method, prompt a user for values for each field for a Checkup, and return a Checkup object to the main() method where it is assigned to one of main()’s Checkup objects. Then, in main(), pass each Checkup object in turn to a showValues()method that displays the data. Blood pressure values are usually displayed with a slash between the…
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…
create a class named checkup with fields that you read a patient number, blood pressure figures (systolic or diastolic), and two cholesterol figures (ldl and hdl). include a method named computeratio() that divides ldl cholesterol by hdl cholesterol and displays the result. include an additional method named explainratio() that explains that hdl is knowns as “good cholesterol” and that a ratio of 3.5 or lower is considered optimum pseudo code
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 named checkup with fields that you read a patient number, blood pressure figures (systolic or diastolic), and two cholesterol figures (ldl and hdl). include a method named computeratio() that divides ldl cholesterol by hdl cholesterol and displays the result. include an additional method named explainratio() that explains that hdl is knowns as “good cholesterol” and that a ratio of 3.5 or lower is considered optimum java programarrow_forwarda. Create a class named Invoice that contains fields for an item number, name, quantity, price, and total cost. Create instance methods that set the item name, quantity, and price. Whenever the price or quantity is set, recalculate the total (price times quantity). Also include a displayLine() method that displays the item number, name, quantity, price, and total cost. Save the class as Invoice.java. b. Create a class named TestInvoice whose main() method declares three Invoice items. Create a method that prompts the user for and accepts values for the item number, name, quantity, and price for each Invoice. Then display each completed object. Save the application as TestInvoice.java.arrow_forwarda. Modify the 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. Create an application that demonstrates each method works correctly. 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.java application to ensure that the overloaded constructor worksarrow_forward
- jada please Create a class named Purchase. Each Purchase contains an invoice number, amountof sale and sales tax. Include getter and setter methods for each property.Write a method called InvoiceTotal to compute the total of invoice. Save this infile called Purchase.javaCreate another class with the following:In this class, create a Purchase Object after prompting the user for necessarydetails.(You need to figure out what to ask the user for).When you prompt the user for invoice number do not let the user proceed unlessthe invoice number is between 5 and 55.For sales amount do not let the user proceed if they enter a negativevalue. After instantiating a Purchase object, show all the properties ofthe invoice object.arrow_forwardCreate a class named Circle with fields named radius, diameter, and area. Include a constructor that sets the radius to 1 and calculates the other two values. Also include methods named setRadius()and getRadius(). The setRadius() method not only sets the radius but also calculates the other two values. (The diameter of a circle is twice the radius, and the area of a circle is pi multiplied by the square of the radius. Use the Math class PI constant for this calculation.) Save the class as Circle.java.arrow_forwardCreate a class named Purchase. Each Purchase contains an invoice number, amountof sale and sales tax. Include getter and setter methods for each property.Write a method called InvoiceTotal to compute the total of invoice. Save this infile called Purchase.javaCreate another class with the following:In this class, create a Purchase Object after prompting the user for necessarydetails.(You need to figure out what to ask the user for).When you prompt the user for invoice number do not let the user proceed unlessthe invoice number is between 5 and 55.For sales amount do not let the user proceed if they enter a negativevalue. After instantiating a Purchase object, show all the properties ofthe invoice object. Javaarrow_forward
- Design a program using a console application in java, named studentMarksReport that will print the final result obtained by a student with the weighting of each module. Make use of a class named Student that contains variables to store the student number, test result, assignment result and exam. Create a constructor that accepts the student number, test result, assignment result and the exam result as parameters and create get methods for the variables (Use Scanner to get variable from the user). Create a subclass called Student_Report that extends the Student class. The Student_Report overrides all getter methods and the constructor from Students. Write code for the print_report method which calculates each assessment weighting as follows: Assessment Weighting Test 25% Assignment 25% Exam 50%arrow_forwardDesign a program using a console application in java NetBeans, named studentMarksReport that will print the final result obtained by a student with the weighting of each module. Make use of a class named Student that contains variables to store the student number, test result, assignment result and exam. Create a constructor that accepts the student number, test result, assignment result and the exam result as parameters and create get methods for the variables (UseJOptionePane to get variable from the user). Create a subclass called Student_Report that extends the Student class. The Student_Report overrides all getter methods and the constructor from Students. Write code for the print_report method which calculates each assessment weighting as follows: test =25% weighting assignment=25%weighting exam=50%weightingarrow_forwardCreate a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and -). Create a default constructor that sets the fields to "O" and "+", and an overloaded constructor that requires values for both fields. Include get and set methods for each field. Save this file as BloodData.java. Create an application named TestBlood Data that demonstrates each method works correctly. Save the application as TestBloodData.java.arrow_forward
- Can you write it in JAVA programming language Add a toString method to your Account class. For the purposes of this assignment, please use the toString display the following: This account contains $x. You have earned $y in the last month. where x is the account balance (please don't format the decimals) and y is the monthly interest earned, obtained from the getMonthlyInterest method. Compile and test in a driver by creating and printing an Account object. Add an equals method to your Account class. Two Account objects are equal if their balance and annualInterestRates are equal. Compile and test in your driver by creating 2 Account objects to see if they are equal.arrow_forwardCreate a class named printing that will include a method called print details, that will print the customer invoice. In the printing class include another method called customer purchase report which will display the following information: All in Javaarrow_forwarddesign a class named Rectangle to represent a rectangle. The class contains: A method named getPerimeter() that returns the perimeter. Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with the specified width and height. A method named getArea() that returns the area of this rectangle. design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle. Draw the UML diagram for the class and then implement the class. Write a test program that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width,…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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