Forums Hà Nội Aptech
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.
Tìm kiếm
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» TUYỂN SINH KHÓA ĐÀO TẠO LUVINA ACADEMY X/2014 (Hệ Sơ cấp)
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyFri Jan 10, 2014 5:08 pm by trangan

» Luvina - Tuyển sinh Luvina Academy IX/2013
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyTue Apr 09, 2013 2:21 pm by trangan

» LUVINA ACADEMY VIII TUYỂN SINH 2012
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyMon Sep 17, 2012 3:16 pm by trangan

» Tuyển sinh khóa học lập trình viên_Luvina Academy VII (Hệ sơ cấp)
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyTue Jul 10, 2012 7:01 pm by trangan

» Xin đề thi thực hành,lý thuyết và đáp án của môn Developing Web Services with Java
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyTue Jan 10, 2012 12:58 pm by JinHoVN

» Nhờ các PRO vào làm giúp kái đề PCS này với
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyFri Jan 06, 2012 1:06 pm by phongvan1991

» Đề cương ôn tập môn CF
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyThu Nov 10, 2011 8:20 pm by thanhnc_b01392

» xin slide môn C
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptySun Sep 04, 2011 5:33 pm by anhchang064

» Drugs In Japan
CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE EmptyTue Aug 02, 2011 5:58 am by Khách viếng thăm

Affiliates
free forum

May 2024
MonTueWedThuFriSatSun
  12345
6789101112
13141516171819
20212223242526
2728293031  

Calendar Calendar

Affiliates
free forum


CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE

Go down

CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE Empty CHAPTER 8 ASSIGNMENT - LEARN JAVA BY EXAMPLE

Bài gửi  Admin Mon Aug 23, 2010 10:13 pm

Exercise 1 :
1. sDeclare a class, calArea, with length and width as its members of type double. The class should define one constructor to initialize the instance variables length and width. The class will have one more constructor to accept two values and assign them to length and width respectively. Further the class should define two methods - area() and display(). The area() method should compute the area and return it. The display() method will be used to display the returned value.


2. Write a class called distance which has two members feet and inches of type double. Define a method calculate() to accept a value indicating number of inches, and display the corresponding value in feet (and inches).

Exercise 2 :

Create a class called Employee with name and salary of type String and double respectively. Define a method calculatepay() in the Employee class with no code as it will be overridden in the subclasses. Create three subclasses - Manager, Scientist and Laborer from the Employee class. The Manager class has a member called business_amount of type double. The Scientist class has a member called publication of type int. The Laborer class has a member named hrsworked of type int. All these subclasses have to override a method called calculatepay and calculate the total_pay based on the formula given:

total_pay=salary + commission;

In the Manager class, if the business_amount is greater than Rs. 50,000, the commission should be calculated as 10% of the business_amount. Otherwise the commission should be calculated as 5% of the business_amount.

In the Scientist class, if the number of publication is more than 25, the commission should be calculated as 20% of salary. If number of publication is less than 25, then the commission should be calculated as 10% of salary.

For the Laborer class the commission should be calculated as 15% of salary, if hrsworked is more than 50. If hrsworked is less than 50 then the commission is 8% of salary.

All these subclasses will have a display() method to display the name and salary. Additionally these display() methods will display business_amount, publication and hrsworked for the classes Manager, Scientist, and Laborer respectively.


Lời giải: [You must be registered and logged in to see this link.]
Admin
Admin
Admin
Admin

Tổng số bài gửi : 31
Join date : 23/08/2010
Age : 35
Đến từ : Hà Nội 5

https://hn-aptech.forumvi.com

Về Đầu Trang Go down

Về Đầu Trang

- Similar topics

 
Permissions in this forum:
Bạn không có quyền trả lời bài viết