You are on page 1of 8

# FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes, Objects & Relationship ASSESSMENT: HO NUM

: 1 DURATION: 2 Ho!rs CODE: BCS2143

MARKS:

Name" ##################################################

MATRIC NUM: ____________________

2.

After finished, zip/rar your folder (right clic folder !" #end to !" \$ompressed (%ipped/&A&' folder' and u!"i# o\$li\$e u i\$% "oodle.&'lea e C(e)* your Sye* e\$ !efore Su!"i#+ 'lea e "a*e ure you e\$d #(e )orre)# file/folder, Triple )(e)* your file/folder !efore u!"i io\$, Se\$di\$% #(e -ro\$% file/folder or a\$ e"p#y file/folder -ill re)ei.e 0 "ar* , )his *+) ,ill carried out 2-. of your course mar .

3,

(.

1

/ssume The 0ouses O"ner "ill pa+ all the \$ills1. ou must use the portion o! Main class in Figure 2 and the UML diagram in Figure 3 to ans"er this #uestion. ElectricBill class. "ater \$ill. \$an% loan \$ill and rent house income is gi&en in Figure '. WaterBill class. Objects & Relationship ASSESSMENT: HO NUM: 1 DURATION: 2 Ho!rs CODE: BCS2143 MARKS: Name" ################################################## MATRIC NUM: ____________________ QUESTION Write a complete Main class. -ro!it is income minus the total \$ill . Figure (. CableTv class . RentHouse class. The calculations !or the electric \$ill. Figure ) and Figure *.BankLoanBill class and Income class to produce the output as Figure 1. and \$an% loan \$ill !or a rented house. "ater \$ill. 2 . respecti&el+. ca\$le T. The total \$ill is the sum o! electric \$ill.FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes.

-&ent *ouse /ame: #ri =u Electric 9ill: &11--.-)otal 9ills: &1(--.-Profit: &11<-.>< 9an 2oan 9ill: &11<--.-\$a8le )5 : &1(9an 2oan 9ill: &1..-:ater 9ill: &1(<.<\$a8le )5: &1>9an 2oan 9ill: &1?--.< 4ncome: &12<--.<4ncome: &112--.-Profit: &1(@>.>2.-:ater 9ill: &12-.FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes.-4ncome: &1<<-.-Profit: &1.<&ent *ouse /ame: 4ndera Pura Electric 9ill: &12<-.-)otal 9ills: &12-21.-)otal 9ills: &1>2<.--.-:ater 9ill: &1@-.<\$a8le )5: &12--.@(.-3 .?< )+)A2 P&+A4): &12. Objects & Relationship ASSESSMENT: HO NUM: 1 DURATION: 2 Ho!rs CODE: BCS2143 MARKS: Name" ################################################## MATRIC NUM: ____________________ &E/) *+0#E 1+/)*23 4/5E#)1E/) &EP+&) 6666666666666666666666666666666666666 &ent *ouse /ame: 7am8ang &a yat Electric 9ill: &12-.

3??.?.3?.1?.CSport -a%ageC17 houses:2.??>17 @ent0ouse:.67 pu\$lic class 8ain 9 pu\$lic static &oid main.(3. houses7 houses = ne" @ent0ouse:3.>7am8ang &a yat >. ><ou\$leDStore+ Terrace>. >Ao" Bost Terrace>.te5t.FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes. = ne" @ent0ouse.1??. = ne" @ent0ouse. Objects & Relationship ASSESSMENT: HO NUM: 1 DURATION: 2 Ho!rs CODE: BCS2143 MARKS: Name" ################################################## MATRIC NUM: ____________________ Figure 1 import 4a&a.(??.(.>?.CFamil+ -ac%ageC 17 houses:1.2??. args1 9 <ecimalFormat d! = ne" <ecimalFormat.2?.>/partment>.7 houses:?.String:. = ne" @ent0ouse.>Indera -ura>.1(?.>#ri =u >.CSuper -ac%C17 EE Fenerate a report //complete your code for main class here G G Figure 2 ' .1(.

resident.1:ElectricIill H getWaterIill.1:&oid ( .1:Income Income D houseT+pe: String D income-er8onth: dou\$le H Income.1: &oid @ent0ouse DelectricIill: ElectricIill D"aterIill: WaterIill DloanIill: Ian%AoanIill Dincome: Income Drent0ouseName: String H @ent0ouse.1:dou\$le H calculateIill . "aterOld8tr. electNe"8tr.ne"8tr.1: &oid Ian%AoanIill D houseT+pe: String D calculatedIill: dou\$le H Ian%AoanIill. ca\$leT&-a%ange1 H get@esidence. old8tr1 H getBalculatedIill. Objects & Relationship ASSESSMENT: HO NUM: 1 DURATION: 2 Ho!rs CODE: BCS2143 MARKS: Name" ################################################## MATRIC NUM: ____________________ Ba\$leT& Dpac%age:String DcalculatedIill:dou\$le Dset-ac%age.houseT+pe1 H getIncome-er8onth.1:dou\$le H calculateIill.1:WaterIill H getBa\$leT&Iill:Ba\$leT&Iill H getIan%AoanIill. electOld8tr.1: &oid WaterIill D8INI8U8J@/TE:dou\$le Dold8eter:int Dne"8eter:int DcalculatedIill:dou\$le H WaterIill.1:String H getElectricIill.1:Ian%AoanIill H getIncome. houseT+pe. "aterNe"8tr.1:dou\$le H calculateIill .ne"8tr. houseT+pe1 H getBalculatedIill. old8tr1 H getBalculatedIill.FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes.1:dou\$le H calculateIncome.pac%age1 DFetBalculateIill:dou\$le DcalculatedIill:&oid ElectricIill Dold8eter:int Dne"8eter:int DcalculatedIill:dou\$le H ElectricIill.

14f meter used is higher or eEual to 1-. the . meter used 6 ne.<-' +thers. meter C old meter 4f meter used is less than 2. meter C old meter 4f meter used is less than 1-..FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes.2+thers.-meter used 6 ne. Objects & Relationship ASSESSMENT: HO NUM: 1 DURATION: 2 Ho!rs CODE: BCS2143 MARKS: Name" ################################################## MATRIC NUM: ____________________ Figure 3 Balculation !or electric \$ill.ater 8ill 6 minimum rate D (meter used x -.unit.unit. the .ater 8ill 6 minimum rate D (meter used x 1. the electric 8ill 6 meter used x -.unit 8ut less than 2-unit. the electric 8ill 6 meter used x -. )he Balue for minimum rate is &1 . the electric 8ill 6 meter used x -.--' Figure 1? Figure ( ) .(- Figure ' Balculation !or "ater \$ill.

the fee is &11<. the 8an &11<-. Objects & Relationship ASSESSMENT: HO NUM: 1 DURATION: 2 Ho!rs CODE: BCS2143 MARKS: Name" ################################################## MATRIC NUM: ____________________ Balculation !or \$an% loan \$ill. the cost is &1(2 per 1onth.per 1onth./1onth loan 4f the type of rent house is FHou8le!#torey )erraceG. 4f the pac age is F#port Pac ageG. \$ost )erraceG. 4f the pac age is F#uper Pac G. the 8an loan 8ill 6 &1?-.-. Figure 12 Figure * * ./1onth 4f the type of rent house is FApartmentG. the fee is &1>.per 1onth. 4f the type of rent house is F2o.FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes. the 8an 8ill 6 &1./1onth loan 8ill 6 Figure 11 Figure ) -rice !or t& Ba\$le 4f the pac age is FAamily Pac ageG.

FACULTY OF COMPUTER SYSTEMS & SOFTWARE ENGINEERING COURSE: Object Oriented Programming TOPIC: Classes. the rent is &12<-. 4f the type of rent house is FHou8le!#torey )erraceG.per 1onth. the rent is &1<<. 4f the type of rent house is FApartmentG. \$ost!#torey )erraceG. 4f the type of rent house is F2o.per 1onth. Figure 12 Figure K END OF QUE !"ON #\$#E% K . the rent is &112-. Objects & Relationship ASSESSMENT: HO NUM: 1 DURATION: 2 Ho!rs CODE: BCS2143 MARKS: Name" ################################################## MATRIC NUM: ____________________ Balculation !or rent house per month.per 1onth.