Yanbu University College Applied Computer Science (ACS) Introduction to Computer Science (CS 102) Lab Exercise 10

Similar documents
final Methods and Classes

Object-Oriented Programming: Polymorphism Pearson Education, Inc. All rights reserved.

Object-Oriented Programming: Polymorphism

CS111: PROGRAMMING LANGUAGE II

Object-Oriented Programming: Polymorphism

WEEK 13 EXAMPLES: POLYMORPHISM

CS 209 Sec. 52 Spring, 2006 Lab 6 - B: Inheritance Instructor: J.G. Neal

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

Java How to Program, 8/e

CSE 530A. ER Model. Washington University Fall 2013

Object Oriented Programming with C++ (24)

Chapter 7. Inheritance

Enhanced Entity- Relationship Models (EER)

CS111: PROGRAMMING LANGUAGE II

Polymorphism (Deitel chapter 10) (Old versions: chapter 9)

Lecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?

CS112 Lecture: Inheritance and Polymorphism

CS 338 The Enhanced Entity-Relationship (EER) Model

CS313D: ADVANCED PROGRAMMING LANGUAGE

CSCI 200 Lab 2 Inheritance, Polymorphism & Data Streams

Object Oriented Relationships

第三章习题答案 // include definition of class GradeBook from GradeBook.h #include "GradeBook.h"

Write a java program to prints the count of odd and even no s entered.

CS111: PROGRAMMING LANGUAGE II

UNIVERSITI SAINS MALAYSIA. CIT502 Object-Oriented Programming and Software Engineering

Exam Duration: 2hrs and 30min Software Design

9/10/2018 Programming Data Structures Inheritance

IS 0020 Program Design and Software Tools

CS 209 Spring, 2006 Lab 11: Files & Streams Instructor: J.G. Neal

Module Contact: Dr Taoyang Wu, CMP Copyright of the University of East Anglia Version 1

Java Programming Lecture 7

CS313D: ADVANCED PROGRAMMING LANGUAGE

Inheritance Motivation

High-Level Database Models (ii)

CSE Lab 7 Assignment

Chapter (4) Enhanced Entity-Relationship and Object Modeling

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM

Announcement. Agenda 7/31/2008. Polymorphism, Dynamic Binding and Interface. The class will continue on Tuesday, 12 th August

ALIGARH MUSLIM UNIVERSITY Department of Computer Science. JAVA Lab Assignment Course: MCA II nd Semester Academic Session:

Object Oriented Design

CS 209 Sec. 52 Spring, 2006 Lab 5: Classes Instructor: J.G. Neal

Java. Classes 3/3/2014. Summary: Chapters 1 to 10. Java (2)

Job Aid Submit a Direct Retro at UCLA

Chapter 14. Inheritance. Slide 1

Introduction to Object-Oriented Programming

Lab 10: Inheritance (I)

Chapter 14 Inheritance. GEDB030 Computer Programming for Engineers Fall 2017 Euiseong Seo

From ER to Relational Model. Book Chapter 3 (part 2 )

Name: CS 159 Practice Final Fall 2015

Polymorphism. Chapter 4. CSC 113 King Saud University College of Computer and Information Sciences Department of Computer Science. Dr. S.

First Name: AITI 2004: Make-up Exam 1 July 9, Last Name:

Chapter 2a Class Relationships

Software and Programming 1

conditional statements

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4-1

MIS Database Systems Entity-Relationship Model.

The Entity-Relationship Model

Chapter 4. Enhanced Entity- Relationship Modeling. Enhanced-ER (EER) Model Concepts. Subclasses and Superclasses (1)

CSE 1325 Project Description

Revised Guidelines for B.A. Programme Semester II Paper: Database Management System (Meeting held on 15 th Jan 2015)

Name: CS 159 Practice Final Fall 2015

CS 215 Software Design Sample midterm solutions

Conceptual Data Models for Database Design

Netbeans tutorial:

Programming in the large

Dynamics GP SmartList Lab. Matt Mason

This exam is open book. Each question is worth 3 points.

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

Lesson 14: Abstract Classes and Interfaces March 6, Object-Oriented S/W Development with Java CSCI 3381

Final Examination Semester 3 / Year 2008

COIS Databases

Object Oriented Programming

COMP 244. ER-Diagram Notations. Entity-Relationship Diagrams DATABASE CONCEPTS & APPLICATIONS. Database Concepts & Applications 1.

Hiring a Hourly Internal Employee w/o an Employee ID Number

Solutions for H7. Lecture: Xu Ying Liu

Inheritance. Overview. Chapter 15 & additional topics. Inheritance Introduction. Three different kinds of inheritance

Name Return type Argument list. Then the new method is said to override the old one. So, what is the objective of subclass?

CSIS 10A Practice Final Exam Solutions

The Relational Model (ii)

Intermediate Programming

CPS122 Lecture: Encapsulation, Inheritance, and Polymorphism

CO Java SE 8: Fundamentals

LAB 3 Notes. Codd proposed the relational model in 70 Main advantage of Relational Model : Simple representation (relationstables(row,

CS 215 Software Design Sample Midterm Questions

Practice Midterm Exam. Start with the ones that you consider to be easiest, then move to those that may take more time.

High Level Database Models

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

COMP 244 DATABASE CONCEPTS & APPLICATIONS

M.Com IT (Information Tech.) -Scheme with Practical List Colleges BHARATHIAR UNIVERSITY,COIMBATORE

Inheritance. Chapter 15 & additional topics

Java and OOP. Part 3 Extending classes. OOP in Java : W. Milner 2005 : Slide 1

1/24/2012. Chapter 7 Outline. Chapter 7 Outline (cont d.) CS 440: Database Management Systems

CS 113 PRACTICE FINAL

Introduction to Programming System Design CSCI 455x (4 Units)

VALLIAMMAI ENGINEERING COLLEGE

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

CMPT 280 Intermediate Data Structures and Algorithms

PRACTICAL LIST FOR EVEN SEMESTERS (PGDCA/MCA/MSC (CS))

BBM 102 Introduction to Programming II Spring 2017

Homework 2. Develop an EER model for the following situation using the EER diagram,

Transcription:

Yanbu University College BACHELOR OF SCIENCE IN Applied Computer Science (ACS) Introduction to Computer Science (CS 102) Third Semester Academic Year 2011 2012 Lab Exercise 10 Course Instructor: Mohammed Rafi / Rasheed Ricardo 1. Create an abstract class Staff which has two protected instance variables staffcode type String, staffname type String and performs the following tasks. variable. b. Provide get and set methods for each of the instance variables. c. Provide an abstract method name calsalary and return type is double. d. Provide a method tostring to return the staffcode and staffname. Create a class Engineering which inherits from the Staff and has two instance variables experience type int and salary type double and performs the following tasks. b. Add a method called calsalary which returns the calculated salary depending on experience. If the experience is zero it return the same salary, if the experience is > 2 and <= 4 it will return (salary + salary * 0.10) and else it will return (salary + salary * 0.50). c. Add a method called tostring which returns to return the staffcode, staffname, experience, and calculated salary. Create a class StaffApp which performs the following tasks. a. Read the staffcode, staffname, experience and salary from the user. b. Create an object for Enineering. c. Display the information 1

2. Create a class StaffApp which performs the following tasks. a. Create an array objects for Engineering using ArrayList b. Read the staffcode, staffname, experience and salary from the user until staff code is n. c. Display the information 3. 2

4. Write a test application MovableTest to test the methods moveup(), movedown(), moveleft(), moveright(). 5. Create abstract class Employee with two instance variables name type string, ssn type string and perform the following tasks. a. Provide a parameterized constructor which initializes the two instance variables. b. Provide get and set methods for each of the instance variables. c. Provide abstract method earnings which returns double. d. Provide a tostring method which returns the Name and ssn of the employee. Create a class SalariedEmployee which inherits from abstract class Employee and has instance variable weeklysalary type double and perform the following tasks. b. Provide get and set methods for weeklysalary. If the salary < 0 then the weekslary is set 0.0 or else set to salary. c. Provide earnings method which returns the weeksalary. 3

d. Provide a tostring method which return the name, ssn and earnings. Create a class HourlyEmployee which inherits from abstract class Employee and has two instance variable hourlywage type double and hours type double and perform the following tasks. b. Provide get and set methods for hourlywage and hours. If the hourlywage < 0 then the hourlywage is set 0.0 or else set to hourlywage. If the hoursworked >= 0.0 and <= 168.0 the hours set to hoursworked or else 0.0 c. Provide earnings method which performs the following. It returns hourlywage * 40 if hours < 40 or else returns 40 * hourlywage + (hours 40) * wage * 1.5 d. Provide a tostring method which return the name, ssn hourlywage, hours and earnings. Create an application called payroll which creates an object for above two subclasses and prints the information. 6. Create an interface named payable which has one method named getpaymentamout and returns double. Create a class invoice to represent a simple invoice that contains billing information of only one kind of part. The class has four instance variables partnumber type string, partdescription type String, quantity type integer, priceperitem type double, this is class is implemented form the payable interface and performs the following tasks. a. Provide a parameterized constructor which takes four parameters and initializes the instance variables. b. Provide set and get methods for each of the instance variables. The set method for the quantity checks the 4

quantity if it is less than 0.0 set to 0 or else set the quantity. The set method for the priceperitem checks for the price if the price is less than 0 it sets to 0.0 or else set the price. c. Provide a tostring method which returns partnumber, partdescription, quantity, priceperitem. d. Provide a method getpaymentamount which calculates and returns the calculated value. Quantity * PricePerItem Create a test application named PayableInterfaceInoviceTest which creates array of objects for the class invoice and prints the information. 7. Create an interface named payable1 which has one method named getpaymentamout and returns double. Create abstract class Employee1 with two instance variables name type string, ssn type string and perform the following tasks. a. Provide a parameterized constructor which initializes the two instance variables. b. Provide get and set methods for each of the instance variables. c. Provide a tostring method which returns the Name and ssn of the employee. Create a class SalariedEmployee1 which inherits from abstract class Employee and has instance variable weeklysalary type double and perform the following tasks. 5

b. Provide get and set methods for weeklysalary. If the salary < 0 then the weekslary is set 0.0 or else set to salary. c. Provide getpaymentamount method which returns the weeksalary. d. Provide a tostring method which return the name, ssn and earnings. Create a test application named PayableInterfaceTest which creates array of objects for the classes invoice and SalariedEmployee and prints the information. Increase the weeklysalary of each of SalariedEmployee by 10% and the SalariedEmployee. 6

7