SlideShare a Scribd company logo
1 of 2
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.
[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.]

More Related Content

Similar to Task 1

Create a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdfCreate a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdffacevenky
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxssuser562afc1
 
Cis 355 i lab 3 of 6
Cis 355 i lab 3 of 6Cis 355 i lab 3 of 6
Cis 355 i lab 3 of 6helpido9
 
Ee java lab assignment 2
Ee java lab assignment 2Ee java lab assignment 2
Ee java lab assignment 2Kuntal Bhowmick
 
Ee java lab assignment 2
Ee java lab assignment 2Ee java lab assignment 2
Ee java lab assignment 2Kuntal Bhowmick
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxtiffanyd4
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxVictormxrPiperc
 
Program Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docxProgram Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docxsharold2
 
Program Specifications in c++ Develop an inventory management syste.docx
Program Specifications in c++    Develop an inventory management syste.docxProgram Specifications in c++    Develop an inventory management syste.docx
Program Specifications in c++ Develop an inventory management syste.docxsharold2
 
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docxLynellBull52
 
Looks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdfLooks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdfbadshetoms
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfAlanSmDDyerl
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxLucky Ally
 
machine learning basic-1.pptx
machine learning basic-1.pptxmachine learning basic-1.pptx
machine learning basic-1.pptxDrLola1
 
CIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docx
CIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docxCIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docx
CIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docxsleeperharwell
 
Cyber Security wk 8 paperAssignment 2 Implementing Network a.docx
Cyber Security wk 8 paperAssignment 2 Implementing Network a.docxCyber Security wk 8 paperAssignment 2 Implementing Network a.docx
Cyber Security wk 8 paperAssignment 2 Implementing Network a.docxtheodorelove43763
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces HomeWork-Fox
 
Resources the Final Project Overview and the Final Project Interv.docx
Resources the Final Project Overview and the Final Project Interv.docxResources the Final Project Overview and the Final Project Interv.docx
Resources the Final Project Overview and the Final Project Interv.docxdebishakespeare
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docxhoney690131
 

Similar to Task 1 (20)

Create a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdfCreate a class Person with two instance variables of type String cal.pdf
Create a class Person with two instance variables of type String cal.pdf
 
Assignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docxAssignment Instructions 2_7aExplain the interrelationships bet.docx
Assignment Instructions 2_7aExplain the interrelationships bet.docx
 
Cis 355 i lab 3 of 6
Cis 355 i lab 3 of 6Cis 355 i lab 3 of 6
Cis 355 i lab 3 of 6
 
Ee java lab assignment 2
Ee java lab assignment 2Ee java lab assignment 2
Ee java lab assignment 2
 
Ee java lab assignment 2
Ee java lab assignment 2Ee java lab assignment 2
Ee java lab assignment 2
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docx
 
Program Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docxProgram Specifications in c++ Develop an inventory management system f.docx
Program Specifications in c++ Develop an inventory management system f.docx
 
Program Specifications in c++ Develop an inventory management syste.docx
Program Specifications in c++    Develop an inventory management syste.docxProgram Specifications in c++    Develop an inventory management syste.docx
Program Specifications in c++ Develop an inventory management syste.docx
 
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx© 2014 Laureate Education, Inc.   Page 1 of 4 Retail Trans.docx
© 2014 Laureate Education, Inc. Page 1 of 4 Retail Trans.docx
 
Looks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdfLooks like the questions has been ask before but isnt answered cor.pdf
Looks like the questions has been ask before but isnt answered cor.pdf
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdf
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docx
 
machine learning basic-1.pptx
machine learning basic-1.pptxmachine learning basic-1.pptx
machine learning basic-1.pptx
 
CIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docx
CIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docxCIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docx
CIS 25 SPRING 2020FINAL Due 1159 PM May 22 (this is a har.docx
 
Cyber Security wk 8 paperAssignment 2 Implementing Network a.docx
Cyber Security wk 8 paperAssignment 2 Implementing Network a.docxCyber Security wk 8 paperAssignment 2 Implementing Network a.docx
Cyber Security wk 8 paperAssignment 2 Implementing Network a.docx
 
OOP Assignment 03.pdf
OOP Assignment 03.pdfOOP Assignment 03.pdf
OOP Assignment 03.pdf
 
CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces  CIS 247C iLab 4 of 7: Composition and Class Interfaces
CIS 247C iLab 4 of 7: Composition and Class Interfaces
 
Resources the Final Project Overview and the Final Project Interv.docx
Resources the Final Project Overview and the Final Project Interv.docxResources the Final Project Overview and the Final Project Interv.docx
Resources the Final Project Overview and the Final Project Interv.docx
 
1 Goals. 1. To use a text file for output and later for in.docx
1 Goals. 1. To use a text file for output and later for in.docx1 Goals. 1. To use a text file for output and later for in.docx
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.]