The Artima Developer Community
Sponsored Link

Java Answers Forum
Help For these Java Programs!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Mark Hu

Posts: 1
Nickname: markhu
Registered: Apr, 2016

Help For these Java Programs! Posted: Apr 21, 2016 12:00 PM
Reply to this message Reply
Advertisement
1. Write a class that represents triangle named Triangle, the class must have the following members:
private double height;//Height
private double base;//Base length
public Triangle(double h, double b);//Constructor
public void setHeight(double x);//Sets height
public double getHeight();//Gets height
public void setBase(double x);//Sets base length
public double getBase();//Gets base length
public double getArea();//Returns the area of the triangle.

2. Write a class Employeethat represents an employee of some organization, the class should contain the following members:
private int id;//Employee id
private String name;//Employee name
private int type;//1 = employee, 2 = manager
private double baseSalary;//Base salary
public Employee(int _id, String _name);//Constructor
public void setID(int x);//id mutator
public void setName(int x);//name mutator
public int getID();//id accessor
public String getName();//name accessor
public double getSalary();
//if manager, add 10% to base salary
public void setBaseSalary(double bs);//sets base salary.

Topic: Java - Lotto Previous Topic   Next Topic Topic: Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use