# lab no 2 tass oop.pdf - 0BJECT ORIENTED PROGRAMMING...

• 12

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 5 out of 12 pages.

0BJECT ORIENTEDPROGRAMMINGSUBMITTED TO ENGRINEER HAMID SAEEDTASSADUQ RASHEEDFA19-BEE-040LAB NO 02:Object Oriented Modeling & Control Structures
0BJECT ORIENTED PROGRAMMINGTASSADUQ RASHEED1EXERCISE TASK 1:Write a program that specifies whether a given number (x) falls in one of the following categories (give x a valuefrom the code, don't read from user):• 0 to 9• 10 to 19• 20 to 29None of the categoriesFor example, if x = 5, program should print "0 to 10", and if x = 44 it should print "None".PROGRAM1.packagetask1;2.3.public classTask1{4.5.6.public static voidmain(String[]args) {7.intx=15;8.if(x>=0&&x<=9){9.System.out.println("0 to 9");10.}11.else if(x>=10&&x<=19){12.System.out.println("10 to 19");13.}14.else if(x>=20&&x<=29){15.System.out.println("20 to 29");16.}17.else{18.System.out.println("none");19.}20.}21.}OUTPUTrun:10to19BUILD SUCCESSFUL(total time:0seconds)EXERCISE TASK 2:
0BJECT ORIENTED PROGRAMMINGTASSADUQ RASHEED32. Subtraction (-).

Course Hero member to access this document

Course Hero member to access this document

End of preview. Want to read all 12 pages?