Instance methods

Assignment Help JAVA Programming
Reference no: EM13159583

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() );

Reference no: EM13159583

Questions Cloud

Construct confidence intervals for the given population mean : In order to do so, they review 42 service calls and construct a 95% confidence interval for population mean: (2.468, 2.743). What can we conclude about the significance test of Ho: mu = 2.6 vs Ha: mu does not equal 2.6?
Compute the break even point in dollars : Quiltworks company reported actual sales of $2,000,000, and fixed costs of $450,000. The contribution margin ratio is 30%. (a) compute the break even point in dollars
What instructions would you give people in a group session : What instructions would you give people in a group session about how to get their computers to look standardized?2. What policy would you suggest for what to put on the screen so it does not offend anyone?
How many moles of khp were originally present : dissolved .31 grams of KHP in 25 ml of water and it required 15.5ml of NaOH to reach end of titration, how many moles of KHP were originally present before the addition of the NaOH?
Instance methods : 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.
Prepare the paid-in capital portion : Prepare the paid-in capital portion of the stockholders' equity section at December 31, 2007.
Calculate the total amount of heat energy : calculate the total amount of heat energy that must be removed to convert 34.0g of steam to water at 25 Celsius
Review of new sources of air pollution : Compare and contrast how treatment and regulation of existing air pollution sources differ from that of a review of new sources of air pollution.
Design a class named employeerecord : Design a class named EmployeeRecord that holds an employee's ID number, name, and payrate. Include mutator methods to set the values for each data field and output the values for each data field. Create the class diagram and write the code that

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create java program to describe inheritance and polymorphism

Create a Java program based on the geometric shapes example described at the beginning of this lesson using Classes Square, Triangle, Rectangle, and Circ leto help describe inheritance and polymorphism.

  String that contains at least five letters

Write an application that prompts the user for a String that contains at least five letters and at least five digits. Continuously reprompt the user until a valid String is entered. Display a message indicating whether the user was successful or did ..

  Develop class which implements interface

Let the ADT called SquareMatrix. (The matrix can be represented by 2-D array of ints w/ n rows and n columns.) Write specification for ADT as Java interface. Develop the class which implements interface.

  Program to find maximum-minimum of sequence of values

Common task which should be done in loop is to find maximum and minimum of sequence of values. File Temps.java contains program which reads in sequence of hourly temperature readings over 24- hour period.

  Write a class that implements an ordered list of strings

In this problem you will write a class that implements an ordered list of Strings.

  Recognize one high severity vulnerability for computer

Recognize one high severity vulnerability for each computer (if there is one). Explain vulnerability and describe control(s) to minimize risk from vulnerability.

  How to count number of objects (instances) created

How to count number of objects (instances) Created, use java code and please be descriptive

  Mvc pattern and servlet

When you use the MVC pattern, the controller directs the flow of control to

  Prepare a java simulation program

Given a hash function h, prepare a java simulation program to determine each of the subsequent quantities after 0.8*tablesize random keys have been generated. The keys should be random integers.

  Solving programming problems

Write a computer program that will figure out the total of an order when given the amount of the order ($1000) and a sales tax rate of eight percent.

  Write down the java code for the bank

Write down the java code for the bank of Fraud. User is presented with menu which looks something like this: 1. Deposit 2. Withdrawal 3. Check Balance 4. Exit.

  Write java program to reverse contents of original array

Write down the Java program method named reversal which returns the new array which is a reversal of original array. Use [5.0, 4.4, 1.9, 2.9, 3.4, 3.5] to test method.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd