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

  Write a java program using array to auto-grade exams

Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C, D) for each student.

  Write various bindings to determine semantics

Write the various bindings that are required to determine the semantics when statement is executed. For each binding, indicate binding time used for language. Describe your answer.

  Develop java code to compute monthly rent for housing units

Develop a java code that computes monthly rent for 3 housing units namely Bungalows,Apartments and hostels. All housing units have got size,color and monthly rental rate.

  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.

  Enterprise java beans (ejb) in software development

Enterprise Java Beans (EJB) in software development, EJB technology, EJB application, Stateless Session Beans (SLSB), Stateful Session Beans (SFSB), Message Driven Bean (MDB), Entity Bean

  Construct java program named collegelist

Construct a set of classes for a college to use in many student service and personnel applications. Classes you require to design include following:

  How to access to elements of document object model

To limit creation of malicious code, do you believe that access to elements of document object model and some Javascript functionality be limited?

  Design an abstract data type in java

Design an abstract data type in Java that represents a musical pitch

  Implementation of memory management

Implementation of memory management

  Java script program for song

Construct a JavaScript program that declares and prints an array that includes at least twenty of your favorite songs.

  Alter the prototype form page by javascript function

Alter the prototype form page so that when JavaScript function has verified that all the required fields have been filled, cookie is added to user's computer.

  Executing stringed musical instrument class

Create and execute a stringed musical instrument class.

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