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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic 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