1 Goals. 1. To use a text file for output and later for in.docx
Task 1
1. LAB-1
Task-1:(Invoice Class) Create a class called Invoice that a hardware store might use
to representan invoice for an item sold at the store. An Invoice should include four
pieces of information asinstance variables—a part number (type String), a part
description (type String), a quantity of theitem being purchased (type int) and a price per
item (double). Your class should have a constructorthat initializes the four instance
variables. Provide a set and a get method for each instance variable.In addition, provide
a method named getInvoiceAmount that calculates the invoice amount (i.e.,multiplies
the quantity by the price per item), then returns the amount as a double value. If
thequantity is not positive, it should be set to 0. If the price per item is not positive, it
should be set to0.0. Write a test application named InvoiceTest that demonstrates class
Invoice’s capabilities.
Task-2:(Computerization of Health Records) A health care issue that has been in the
news lately isthe computerization of health records. This possibility is being approached
cautiously because ofsensitive privacy and security concerns, among others.
Computerizing health records could make it easier for patients to share their health
profiles and historiesamong their various health care professionals. This could improve
the quality of health care,help avoid drug conflicts and erroneous drug prescriptions,
reduce costs and, in emergencies, couldsave lives. In this exercise, you’ll design a
“starter” HealthProfile class for a person. The class attributesshould include the
person’s first name, last name, gender, date of birth (consisting of separateattributes for
the month, day and year of birth), height (in inches) and weight (in pounds). Your
classshould have a constructor that receives this data. For each attribute, provide set
and get methods.The class also should include methods that calculate and return the
user’s age in years, maximumheart rate and target-heart-rate range (see Exercise
3.16), and body mass index (BMI; seeExercise 2.33). Write a Java application that
prompts for the person’s information, instantiates anobject of class HealthProfile for that
person and prints the information from that object—includingthe person’s first name, last
name, gender, date of birth, height and weight.
Task-3:(Date Class) Create class Date with the following capabilities:
a) Output the date in multiple formats, such as
MM/DD/YYYY
June 14, 1992
DDD YYYY
b) Use overloaded constructors to create Date objects initialized with dates of the
formatsin part (a). In the first case the constructor should receive three integer values.
In thesecond case it should receive a String and two integer values. In the third case it
shouldreceive two integer values, the first of which represents the day number in the
year.
2. [Hint: To convert the String representation of the month to a numeric value,
compareStrings using the equals method. For example, if s1 and s2 are Strings, the
methodcall s1.equals( s2 ) returns true if the Strings are identical and otherwise
returnsfalse.]