SlideShare una empresa de Scribd logo
1 de 2
Exercises #1
        Print(or photocopy) the whole document and write your answers on the succeeding pages. (Handwritten only)


Name: _____________________________Schedule:_______________Points:___________

1.A Reference Class

         Create a class called Invoice that a hardware store might use to represent an invoice
for an item sold at the store. An Invoice should include four pieces of information as instance
variables – a part number(String), a part description(String), a quantity of the item being
purchased(int) and a price per item(double). Your class should have a constructor that
initializes the four instance variables. Provide mutator and accessor methods for each instance
variable. In addition, provide a method named getInvoiceAmount that calculates the invoice
amount(multiply the quantity by the price per item), then returns the amount as a double
value. If the quantity is not positive, it should be set to 0. If the price per item is not positive,
it should be set to 0.0. Draw the UML diagram for the class.

1.B Main Class

        Write a test application named InvoiceTest that demonstrates class Invoice’s
capabilities.

2.A Reference Class
        Create a class named Employee that includes three pieces of information as instance
variables – a first name(String), a last name(String) and a monthly salary(double). Your class
should have a constructor that initializes the three instance variables. Provide a set and get
method for each instance variable. Draw the UML diagram for the class.

2.B Main Class
        Write a test application named EmployeeTest that demonstrates class Employee’s
capabilities. Create two Employee objects and display each object’s salary. Then give each
Employee a 10% raise and display each Employee’s yearly salary again.

3.A
(The Rectangle class) 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 string data field named color that specifies the color of a rectangle.
           Hypothetically, assume that all rectangles have the same color. The default color is
           white.
          A no-arg constructor that creates a default rectangle.
          A constructor that creates a rectangle with the specified width and height.
          The accessor and mutator methods for all three data fields.
          A method named getArea() that returns the area of this rectangle.
          A method named getPerimeter() that returns the perimeter.

3.B
Draw the UML diagram for the class. Write a test program that creates two Rectangle
objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the
second object. Assign color red to all Rectangle objects. Display the properties of both
objects and find their areas and perimeters.
4.A
(The Fan class) Design a class named Fan to represent a fan. The class contains:

         Three constants named SLOW, MEDIUM, and FAST with values 1, 2, and 3 to denote the
          fan speed.
         An int data field named speed that specifies the speed of the fan (default SLOW).
         A boolean data field named on that specifies whether the fan is on (default false).
         A double data field named radius that specifies the radius of the fan (default 5).
         A string data field named color that specifies the color of the fan (default blue).
         A no-arg constructor that creates a default fan.
         The accessor and mutator methods for all four data fields.
         A method named toString() that returns a string description for the fan. If the fan is
          on, the method returns the fan speed, color, and radius in one combined string. If the
          fan is not on, the method returns fan color and radius along with the string "fan is
          off" in one combined string.

4.B

Draw the UML diagram for the class. Implement the class. Write a test program that creates
two Fan objects. Assign maximum speed, radius 10, color yellow, and turn it on to the first
object. Assign medium speed, radius 5, color blue, and turn it off to the second object.
Display the objects by invoking their toString method.

5.A
 Create a class called BirthDay that includes three pieces of information as data members –
month (type int), day (type month), and a year (type int). Your class should have a constructor
that initializes the three data members. Provide mutators and accessors for each data member.
Provide a method displayBirthDay that displays the month, day and years separated by
slashes (Example: 12/12/85). Provide another method named toString that will display the
date in words. (Example: twelfth day of December, year one thousand nine hundred
eighty five). Draw the UML diagram for the class.

5.B
Write a test application named BirthDayTest that demonstrates class BirthDay’s Application.


                                           Note: This is worth 250 points. (To be passed on Wednesday)

Más contenido relacionado

La actualidad más candente

R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to MatricesRsquared Academy
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory MappingQundeel
 
One dimensional arrays
One dimensional arraysOne dimensional arrays
One dimensional arraysSatyam Soni
 
Array data structure
Array data structureArray data structure
Array data structuremaamir farooq
 
Ashish garg research paper 660_CamReady
Ashish garg research paper 660_CamReadyAshish garg research paper 660_CamReady
Ashish garg research paper 660_CamReadyAshish Garg
 
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysData Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysMaulen Bale
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array PointerTareq Hasan
 
Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...JenniferBall48
 
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsR Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsRsquared Academy
 
Object Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayObject Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayAndiNurkholis1
 
Identification des systémes dynamiques
Identification des systémes dynamiquesIdentification des systémes dynamiques
Identification des systémes dynamiquesAyoub Moufid
 
Presentation on array
Presentation on array Presentation on array
Presentation on array topu93
 

La actualidad más candente (20)

R Programming: Introduction to Matrices
R Programming: Introduction to MatricesR Programming: Introduction to Matrices
R Programming: Introduction to Matrices
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
 
One dimensional arrays
One dimensional arraysOne dimensional arrays
One dimensional arrays
 
Array data structure
Array data structureArray data structure
Array data structure
 
Ashish garg research paper 660_CamReady
Ashish garg research paper 660_CamReadyAshish garg research paper 660_CamReady
Ashish garg research paper 660_CamReady
 
Lecture4 oopj
Lecture4 oopjLecture4 oopj
Lecture4 oopj
 
Prolog upload
Prolog uploadProlog upload
Prolog upload
 
Array
ArrayArray
Array
 
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysData Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...Write a function called float dotproduct (links to an external site.)(float a...
Write a function called float dotproduct (links to an external site.)(float a...
 
Scalable machine learning
Scalable machine learningScalable machine learning
Scalable machine learning
 
R Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar PlotsR Data Visualization Tutorial: Bar Plots
R Data Visualization Tutorial: Bar Plots
 
Object Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. ArrayObject Oriented Programming - 5.1. Array
Object Oriented Programming - 5.1. Array
 
Identification des systémes dynamiques
Identification des systémes dynamiquesIdentification des systémes dynamiques
Identification des systémes dynamiques
 
Arrays in c_language
Arrays in c_language Arrays in c_language
Arrays in c_language
 
ARRAY
ARRAYARRAY
ARRAY
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Arrays
ArraysArrays
Arrays
 
Java part 2
Java part  2Java part  2
Java part 2
 

Similar a Assignment in java

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
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxLucky Ally
 
This lab must be finished in the lab period. Write a class named Fan .docx
 This lab must be finished in the lab period. Write a class named Fan .docx This lab must be finished in the lab period. Write a class named Fan .docx
This lab must be finished in the lab period. Write a class named Fan .docxKomlin1
 
C programming session 04
C programming session 04C programming session 04
C programming session 04Dushmanta Nath
 
Background This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxBackground This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxrosemaryralphs52525
 
© 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
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classemecklenburgstrelitzh
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arraysenidcruz
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfleventhalbrad49439
 
Lab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and PointersLab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and Pointersenidcruz
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in Carshpreetkaur07
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Tiểu Hổ
 
C programming session 05
C programming session 05C programming session 05
C programming session 05Vivek Singh
 

Similar a Assignment in java (20)

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
 
JAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docxJAVA practical Exam Questions (1).docx
JAVA practical Exam Questions (1).docx
 
Java execise
Java execiseJava execise
Java execise
 
This lab must be finished in the lab period. Write a class named Fan .docx
 This lab must be finished in the lab period. Write a class named Fan .docx This lab must be finished in the lab period. Write a class named Fan .docx
This lab must be finished in the lab period. Write a class named Fan .docx
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
OOP Assignment 03.pdf
OOP Assignment 03.pdfOOP Assignment 03.pdf
OOP Assignment 03.pdf
 
Background This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxBackground This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docx
 
Arrays
ArraysArrays
Arrays
 
© 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
 
Exercise1[5points]Create the following classe
Exercise1[5points]Create the following classeExercise1[5points]Create the following classe
Exercise1[5points]Create the following classe
 
Task 1
Task 1Task 1
Task 1
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
Develop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdfDevelop a system flowchart and then write a menu-driven C++ program .pdf
Develop a system flowchart and then write a menu-driven C++ program .pdf
 
Lab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and PointersLab7: More Arrays, Strings, Vectors, and Pointers
Lab7: More Arrays, Strings, Vectors, and Pointers
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3
 
Sharbani bhattacharya VB Structures
Sharbani bhattacharya VB StructuresSharbani bhattacharya VB Structures
Sharbani bhattacharya VB Structures
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
C programming session 05
C programming session 05C programming session 05
C programming session 05
 
Array sheet
Array sheet Array sheet
Array sheet
 

Último

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Último (20)

Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

Assignment in java

  • 1. Exercises #1 Print(or photocopy) the whole document and write your answers on the succeeding pages. (Handwritten only) Name: _____________________________Schedule:_______________Points:___________ 1.A Reference Class Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables – a part number(String), a part description(String), a quantity of the item being purchased(int) and a price per item(double). Your class should have a constructor that initializes the four instance variables. Provide mutator and accessor methods for each instance variable. In addition, provide a method named getInvoiceAmount that calculates the invoice amount(multiply the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0.0. Draw the UML diagram for the class. 1.B Main Class Write a test application named InvoiceTest that demonstrates class Invoice’s capabilities. 2.A Reference Class Create a class named Employee that includes three pieces of information as instance variables – a first name(String), a last name(String) and a monthly salary(double). Your class should have a constructor that initializes the three instance variables. Provide a set and get method for each instance variable. Draw the UML diagram for the class. 2.B Main Class Write a test application named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again. 3.A (The Rectangle class) 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 string data field named color that specifies the color of a rectangle. Hypothetically, assume that all rectangles have the same color. The default color is white.  A no-arg constructor that creates a default rectangle.  A constructor that creates a rectangle with the specified width and height.  The accessor and mutator methods for all three data fields.  A method named getArea() that returns the area of this rectangle.  A method named getPerimeter() that returns the perimeter. 3.B Draw the UML diagram for the class. Write a test program that creates two Rectangle objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the second object. Assign color red to all Rectangle objects. Display the properties of both objects and find their areas and perimeters.
  • 2. 4.A (The Fan class) Design a class named Fan to represent a fan. The class contains:  Three constants named SLOW, MEDIUM, and FAST with values 1, 2, and 3 to denote the fan speed.  An int data field named speed that specifies the speed of the fan (default SLOW).  A boolean data field named on that specifies whether the fan is on (default false).  A double data field named radius that specifies the radius of the fan (default 5).  A string data field named color that specifies the color of the fan (default blue).  A no-arg constructor that creates a default fan.  The accessor and mutator methods for all four data fields.  A method named toString() that returns a string description for the fan. If the fan is on, the method returns the fan speed, color, and radius in one combined string. If the fan is not on, the method returns fan color and radius along with the string "fan is off" in one combined string. 4.B Draw the UML diagram for the class. Implement the class. Write a test program that creates two Fan objects. Assign maximum speed, radius 10, color yellow, and turn it on to the first object. Assign medium speed, radius 5, color blue, and turn it off to the second object. Display the objects by invoking their toString method. 5.A Create a class called BirthDay that includes three pieces of information as data members – month (type int), day (type month), and a year (type int). Your class should have a constructor that initializes the three data members. Provide mutators and accessors for each data member. Provide a method displayBirthDay that displays the month, day and years separated by slashes (Example: 12/12/85). Provide another method named toString that will display the date in words. (Example: twelfth day of December, year one thousand nine hundred eighty five). Draw the UML diagram for the class. 5.B Write a test application named BirthDayTest that demonstrates class BirthDay’s Application. Note: This is worth 250 points. (To be passed on Wednesday)