A health care issue that has been in the news lately is the computerization of health records. This possibility is being approached cautiously because of sensitive privacy and security concerns, among others. [We address such concerns in later exercises.] Computerizing health records could make it easier for patients to share their health profiles and histories among their various health care professionals. This could improve the qualiry of health care, help avoid drug conflicts and erroneous drug prescriptions, reduce costs and, in emergencies, could save lives. In this exercise, you'll design a "starter" Heal thProfile class for a person. The class attributes should include the person's first name, last name, gender, date of birth (consisting of separate attributes for the month, day and year of birth), height (in inches) and weight (in pounds). Your class should have a constructor that receives this data. For each attribute, provide set and \(g e t\) methods. The class also should include methods that calculate and return the user's age in years, maximum heart rate and target-heart-rate range (see Exercise 3.16 ), and body mass index (BMI; see Exercise 2.33 ). Write a Java application that prompts for the person's information, instantiates an object of class Heal thProfile for that person and prints the information from that object- including the person's first name, last name, gender, date of birth, height and weight- then calculates and prints the person's age in years, BMI, maximum heart rate and target-heart-rate range. It should also display the BMI values chart from Exercise 2.33

Short Answer

Expert verified
Design a HealthProfile class with attributes for personal information, set/get methods, and methods to calculate age, BMI, and heart rate. Write a Java program to demonstrate the class functionalities and display a BMI chart.

Step by step solution

01

Define the HealthProfile Class

Create a class named HealthProfile with the following private attributes: firstName, lastName, gender, birthMonth, birthDay, birthYear, heightInInches, and weightInPounds. Include a constructor that initializes these attributes.
02

Create Set and Get Methods

For each attribute in the HealthProfile class, create a 'set' method to allow updating the attribute and a 'get' method to retrieve its value. For example, provide setFirstName(String firstName) and getFirstName() methods.
03

Calculate Age in Years

Add a method to calculate the user's age in years based on the current date and the user's birth date. Use the birthMonth, birthDay, and birthYear attributes to compute the age.
04

Calculate Maximum Heart Rate

Add a method to calculate the maximum heart rate by subtracting the user's age from 220. This is a commonly used formula for estimating a person's maximum heart rate.
05

Calculate Target-Heart-Rate Range

Incorporate methods to calculate the target-heart-rate range, which is typically 50-85% of the maximum heart rate. Return this range as a string or a two-element array.
06

Calculate Body Mass Index (BMI)

Add a method to calculate the BMI using the formula: BMI = (weightInPounds * 703) / (heightInInches * heightInInches).
07

Create the Java Application

Write a Java program that prompts the user for their personal information, creates an instance of HealthProfile with this data, and displays the user's first name, last name, gender, date of birth, height, weight, age, BMI, maximum heart rate, and target heart rate range.
08

Display the BMI Values Chart

Finally, include in the program output the BMI values chart for reference. The chart shows categories like 'Underweight', 'Normal', 'Overweight', and 'Obese' along with the corresponding BMI ranges.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

Key Concepts

These are the key concepts you need to understand to accurately answer the question.

Java Programming Education
Java is a widely-used programming language acclaimed for its versatility and compatibility across different platforms. When delving into Java programming education, the first step is understanding the basics of syntax and semantics. For instance, in the HealthProfile class example, a student must discern the use of classes, methods, and objects.

Classes serve as blueprints for creating objects, which are instances of classes. Methods within a class are blocks of code that perform specific tasks, like calculating BMI. In learning Java, students move from elementary concepts, such as variables and data types, to more advanced object-oriented programming features like encapsulation, polymorphism, and inheritance, all of which enable the creation of robust and secure applications, like those used for managing health information.
Object-oriented Programming
Object-oriented programming (OOP) is a paradigm centered around objects rather than actions. The key principles include encapsulation, inheritance, and polymorphism. Encapsulation is demonstrated through the HealthProfile class by keeping its attributes private and providing public set and get methods to interact with the data safely. This leads to better data integrity and security, important factors in health information systems.

Inheritance allows new classes to adopt the properties of existing ones, enabling code reusability and efficiency. Although not explicitly highlighted in the HealthProfile example, it’s a crucial aspect when extending functionality. Polymorphism allows for methods to be used in different contexts, adding to the flexibility of the code.
Health Information Systems
Health information systems are increasingly reliant on technology. In our HealthProfile example, managing a patient's data digitally embodies a fundamental application within these systems. It's crucial for such systems to be reliable, secure, and user-friendly to ensure the safe handling of sensitive patient information.

Developing classes like HealthProfile is a fundamental step towards creating comprehensive digital health records. By customizing and extending such classes, developers can integrate various health-related data points, such as medical history or prescription details. This technologically supported approach can enhance patient care coordination and data accessibility for healthcare providers while safeguarding patient privacy.
BMI Calculation in Java
Body Mass Index (BMI) is a measure of body fat based on height and weight that applies to adult men and women. In Java, you can calculate BMI using a simple formula encapsulated in a method. As part of the BMI calculation in Java, the code for computing BMI might look like:

public double calculateBMI() {
return (weightInPounds * 703) / (heightInInches * heightInInches);
}

Through this method in the HealthProfile class, we encapsulate the logic for calculating BMI, demonstrating Java's ability to manage health-related calculations efficiently. Additionally, displaying a BMI chart provides users with valuable context for understanding their health metrics, aligning with the educational goal of aiding user comprehension.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Create a class called Employee that includes three instance variables -a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test application named Employeetest that demonstrates class Employee's capabilities. Create two Employee objects and display each object's yearly salary. Then give each Employee a \(10 \%\) raise and display each Employee's yearly salary again.

Fill in the blanks in each of the following: a) Each class declaration that begins with keyword ______ must be stored in a file that has exactly the same name as the class and ends with the . java file-name extension. b) Keyword ______ in a class declaration is followed immediately by the class's name. c) Keyword ______ requests memory from the system to store an object, then calls the corresponding class's constructor to initialize the object. d) Each parameter must specify both a(n) ______ and \(a(n)\) ______ e) By default, classes that are compiled in the same directory are considered to be in the same package, known as the ______ . f) When each object of a class maintains its own copy of an attribute, the field that represents the attribute is also known as a(n) ______ g) Java provides two primitive types for storing floating-point numbers in memory: ______ and ______ h) Variables of type double represent ______ floating-point numbers. i) Scanner method ______ returns a double value. j) Keyword public is an access ______ k) Return rype ______ indicates that a method will not return a value. I) scanner method ______ reads characters until it encounters a newline character,then returns those characters as a String. \(\mathrm{m}\) ) Class \(\operatorname{Str}\) ing is in package ______ n) \(A(n)\) ______ is not required if you always refer to a class with its fully qualified class name. o) \(A(n)\) ______ is a number with a decimal point, such as 7.33,0.0975 or 1000.12345 p) Variables of type \(f\) loat represent______ floating-point numbers. q) The format specifier ______ is used to output values of type float or double. r) Types in Java are divided into two categories ______ types and ______ types.

What is the difference between a local variable and a field?

Explain why a class might provide a set method and a get method for an instance variable.

Most classes need to be imported before they can be used in an application. Why is every application allowed to use classes System and String without first importing them?

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free