Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

1. Create classes: Triangle, Rectangle, ShapeDemo

a. Triangle class

- instance variables: width, height

- instance methods: setWidth(double w), setHeight(double h), double getWidth(), double getHeight() and double getArea()

* A triangle's area is calculated by width*height*0.5

* all variables are private and methods public.

b. Rectangle class

- instance variables: width, height

- instance methods: setWidth(double w), setHeight(double h), double getWidth(), double getHeight() and double getArea()

* A rectangle's area is calculated by width*height

* all variables are private and methods public.

c. ShapeDemo

Create the main method in which you:

- create objects of Triangle and Rectangle that were defined in a and b.

- assign values for these objects using set methods.

- display areas of the objects you created.

2. Create classes: HourlyEmployee and HourlyEmployeeDemo

a. HourlyEmployee

- instance variables: employeeNumber, employeeName, hoursWorked, hourlyRate.

* employeeNumber and employeeName must be declared as String. hoursWorked is int, and hourlyRate is double.

- instance methods: set and get methods for each instance variable

- addtional instance method: calcMonthlyPay() that calculates a monthly payment.

* calcMonthlyPay() method must return an double value. A monthly payment can be calculated as: hoursWorked* hourlyRate

* all variables are private and methods public.

b. HourlyEmployeeDemo.

- Create the main method. You should include the following code block:

HourlyEmployee he1 = new HourlyEmployee(); //create a new HourlyEmployee object

he1.setEmployeeNumber("000-00-0000"); // enter your student id here.

he1.setEmployeeName("John Doe"); // enter your name

he1.setHourlyRate(10.25); he1.setHoursWorked(80);

System.out.println(he1.getEmployeeName() + "'s payment for this month is: $" + he1.calcMonthlyPay() );

Java, Programming

  • Category:- Java
  • Reference No.:- M9449709

Have any Question?


Related Questions in Java

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As