You are on page 1of 2

September 9, 2018 OBJECT-ORIENTED PROGRAMMING – CS102]

Name : ___________________________________________ ID: _______________ / 20


Duration: 60 minutes

This document is divided into 5 sections:


1. Instructions
2. Assignment objectives
3. Description of problem
4. Sample of output
5. Problem solving tips

INSTRUCTION(S):

You are required to write a program in JAVA based on the problem description given. Read the
problem description and examine the sample of output; then study the program design given.
Using the problem-solving tips as a guide, write a complete program with necessary useful
comment for good documentation. Compile and execute the program.

ASSIGNMENT OBJECTIVE(S):
1. Learning objectives
a. To practice create class with multiple constructors.
b. To apply object-oriented programming concept by producing a small program in JAVA
2. Learning outcomes:
a. Able to analyze small-domain system requirement.
b. Able to produce an executable program using JAVA following object-oriented approach
c. Demonstrate capability to create classes and constructors, declare objects and methods,
use object and methods’ call.

DESCRIPTIONS OF PROBLEM:

DanaStore, a cloth department would like to have a cash register program that can calculate sale
for the store. The store has 4 departments currently Spring Sale. Write a program contained a
class CashRegister which has 4 attributes: department (type: int), description (type: String),
discount (type: double) and total (type: double).

Table 1
Department Description Discount
00 Womens 20%
11 Mens 35%
22 Sportswear 50%
33 Kids No discount

Practical 3 S.H. Haris , Sem 171

Page 1 of 2
September 9, 2018 OBJECT-ORIENTED PROGRAMMING – CS102]

SAMPLE OF OUTPUT:

Enter item detail:


Department: 00
Quantity: 2
Price : 100

-------------------------------------------------------------------
Description Quantity Price Total After Discount
Womens 2 100 $200.00 $160.00

Another item? (Yes – 1, No - 0):> 1

Enter item detail:


Department: 11
Quantity: 1
Price : 100

-------------------------------------------------------------------
Description Quantity Price Total After Discount
Mens 1 100 $100.00 $65.00

Another item? (Yes – 1, No - 0):> 0


Total purchase: $225.00
Exit.

PROBLEM SOLVING TIPS:

Num Tips Grade


a) Class CashReg with four attributes department, description, discount and / 2m
total.

b) Write a constructor than can perform initialization to all data members


according to the data type and specification mentioned in Table 1. /2m

c) public set and get method for all attributes. /3m


d) public method calTotal in which will assign value to total based on this
formula total = total + quantity *(price –price*discount) where price and /3m
quantity are from user.
f) Main program which can create object instance and derive user input
during execution with control of sentinel loop, determine the discount /10m
based on code entered, passed the value to method calTotal() to calculate
total purchase as shown in output.

 Finally, submit your work on Moodle at the link provided.


Practical 3 S.H. Haris , Sem 171

Page 2 of 2

You might also like