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 4PE
Program Plan Intro
a.
Display the blood group and Rh factor
Program plan:
Filename: “BloodData.java”
- Define the “BloodData” class.
- Declare the required variables.
- Define of constructor
- Set the default values
- Define the parameterized constructor.
- Set the values.
- Define “getRhFact” method
- Return the Rh factor
- Define “setRhFact” method
- Set the Rh factor value.
- Define “getBloodType” method
- Return the blood type.
- Define “setBloodType” method
- Set the blood type value.
Filename: “TestBloodData.java”
- Define the “TestBloodData” class.
- Define the main method.
- Create an object for “BloodData” class.
- Display the blood group and Rh factor.
- Set the blood group and Rh factor.
- After setting the blood group and Rh factor display the blood group and Rh factor.
- Create an object for “BloodData” class.
- Display the new blood group and Rh factor.
- Define the main method.
Program Plan Intro
b.
Display the patient id and age
Program plan:
Filename: “BloodData.java”
- Define the “BloodData” class.
- Declare the required variables.
- Define of constructor
- Set the default values
- Define the parameterized constructor.
- Set the values.
- Define “getRhFact” method
- Return the Rh factor
- Define “setRhFact” method
- Set the Rh factor value.
- Define “getBloodType” method
- Return the blood type.
- Define “setBloodType” method
- Set the blood type value.
Filename: “Patient.java”
- Define the “Patient” class.
- Declare the required variables.
- Define of constructor
- Set the default values
- Define the parameterized constructor.
- Set the values.
- Define “getIdNumber” method
- Return the patient id number.
- Define “setIdNumber” method
- Set the patient id number.
- Define “getAge” method
- Return the age.
- Define “setAge” method
- Set the age.
- Define “getBd” method
- Return the blood type.
- Define “setBd” method
- Set the blood type value.
Filename: “TestPatient.java”
- Define the “TestBloodData” class.
- Define the main method.
- Create an object for “Patient” class.
- Display the patient id number and age.
- Set the patient id number and age.
- After setting the patient id number and age display patient id number and age.
- Create an object for “Patient” class.
- Display the new patient id number and age
- Define the main method.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Create 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.
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 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”…
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. note....... solve with javaarrow_forwardCreate an application named RecoveringDemo that declares objects of three types: Patient, Upholsterer, and FootballPlayer. Create an interface named IRecoverable that contains a single method named Recover(). Create the classes named Patient, Upholsterer, and FootballPlayer so that each implements IRecoverable. Create each class’s Recover() method to display an appropriate message. For example: The Patient’s Recover() method should display I am getting better. The Upholsterer's Recover() method should display I have new material for the couch. The FootballPlayer's Recover() method should display I picked up the ball after a fumble.arrow_forwardCreate an application named RecoveringDemo that declares objects of three types: Patient, Upholsterer, and FootballPlayer. Create an interface named IRecoverable that contains a single method named Recover(). Create the classes named Patient, Upholsterer, and FootballPlayer so that each implements IRecoverable. Create each class’s Recover() method to display an appropriate message. For example, the Patient’s Recover() method might display “I am getting better. C# Programmingarrow_forward
- Create a class called Employee that includes three instance variables—afirst name (type String), a last name (type String) and a monthly salary (double). Provide aconstructor that initializes the three instance variables. Provide a set and a get method for eachinstance variable. If the monthly salary is not positive, do not set its value. Write a test applicationnamed EmployeeTest that demonstrates class Employee’s capabilities. Create two Employeeobjects and display each object’s yearly salary. Then give each Employee a 10% raise and displayeach Employee’s yearly salary again.arrow_forwardCreate a class named Ship that has two private fields one for the name (string)of the ship, and the other for the year (string) the ship was built. The classcontains a parameterized constructor to set the values of each field get methods for each of the fields display method to display ship’s information.Create a class named CruiseShip that extends Ship class. CruiseShip class should have a private field for the maximum number of passengers (int).The class contains- a parameterized constructor to set the value of the field- get and set method for the field- a display method that overrides ship class display method anddisplay CruiseShip information.Create an application/class named CruiseShipDemo that allows a user toenter values to create 5 CruiseShip objects and save them in the array. Display the records.The CruiseShipDemo class should have a method named update to updatethe CruiseShips information. The method prompts the user for the ship name, if the requested record does not…arrow_forwardin netbeans Write a complete class named Crab that includes a String property named myColor and an int property named myAge. You must also include a default constructor that initializes myColor to RED and myAge to zero as well as an “other” constructor that accepts two parameters and uses them appropriately. You must also implement the getAge and setAge methods. Next Construct a Crab CB1 object using default constructor and invoke all accessible methods. Construct a second Crab object CB2 using parameterized constructor and invoke all accessible methods. Describe the outcome (default vs parameterized constructor).arrow_forward
- a. Write a FractionDemo program that instantiates several Fraction objects and demonstrates that their methods work correctly. Create a Fraction class with fields that hold a whole number, a numerator, and a denominator. In addition: Create properties for each field. The set access or for the denominator should not allow a 0 value; the value defaults to 1. Add three constructors. One takes three parameters for a whole number, numerator, and denominator. Another accepts two parameters for the numerator and denominator; when this constructor is used, the whole number value is 0. The last constructor is parameterless; it sets the whole number and numerator to 0 and the denominator to 1. (After construction, Fractions do not have to be reduced to proper form. For example, even though 3/9 could be reduced to 1/3, your constructors do not have to perform this task.) Add a Reduce() method that reduces a Fraction if it is in improper form. For example, 2/4 should be reduced to 1/2. Add an operator+() method that adds two Fractions. To add two fractions, first eliminate any whole number part of the value. For example, 2 1/4 becomes 9/4 and 1 3/5 becomes 8/5. Find a common denominator and convert the fractions to it. For example, when adding 9/4 and 8/5, you can convert them to 45/20 and 32/20. Then you can add the numerators, giving 77/20. Finally, call the Reduce() method to reduce the result, restoring any whole number value so the fractional part of the number is less than 1. For example, 77/20 becomes 3 17/20. Include a function that returns a string that contains a Fraction in the usual display format—the whole number, a space, the numerator, a slash (D, and a denominator. When the whole number is 0, just the Fraction part of the value should be displayed (for example, 1/2 instead of 0 1/2). If the numerator is 0, just the whole number should be displayed (for example, 2 instead of 2 0/3). b. Add an operator*() method to the Fraction class created in Exercise 11a so that it correctly multiplies two Fractions. The result should be in proper, reduced format. Demonstrate that the method works correctly in a program named FractionDemo2. c. Write a program named FractionDem03 that includes an array of four Fractions. Prompt the user for values for each. Display every possible combination of addition results and every possible combination of multiplication results for each Fraction pair (that is, each type will have 16 results).arrow_forwardWhich of the following statements is false? a. A class can contain only one constructor. b. An example of a behavior is the SetTime method in a Time class. c. An object created from a class is referred to as an instance of the class. d. An instance of a class is considered an object.arrow_forwardOpen the Palace Solution.sln file contained in the VB2017\Chap10\Palace Solution folder. Use Windows to copy the Rectangle.vb file from the VB2017\Chap10 folder to the Palace Project folder. Then, use the Add Existing Item option on the Project menu to add the file to the project. Modify the Rectangle class to use Double variables rather than Integer variables. Change the name of the GetArea method to GetAreaSqFt. Add another method to the class. Use Get AreaSqYds as the method’s name. The method should calculate and return the area of a rectangle in square yards. The application’s Calculate button should calculate and display the number of square yards of carpeting needed to carpet a rectangular floor. Code the btnCalc_Click procedure. Display the number of yards with one decimal place. Save the solution and then start and test the application.arrow_forward
- Everything is in the attached picture! Thank you so much!arrow_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_forward11. Which among the following classes are used in decoding data? They don't have to be used together every time. Select all answers that apply. Take note that this is a right minus wrong question. Which among the following classes are used in decoding data? They don't have to be used together every time. Select all answers that apply. Take note that this is a right minus wrong question. 1. PropertyListDecoder 2.JSONDecoder 3.URL 4. FileDecoderarrow_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,Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher: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,
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