0% found this document useful (0 votes)
51 views84 pages

JavaAssignment (1,2,3,4,5,6,7,9)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
51 views84 pages

JavaAssignment (1,2,3,4,5,6,7,9)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
| -Assigament No. 1 Name - Prerana Balaso Desai Taal class —8CS-H Roll No-58 Title- Basics of Jova. Sub: Java. Qs) Watte oO program 10 demonGtrote Aiffer- ent type of dototyes¢ Use al) the types- é int. byte, short, boolean long, double, float, rt @D Late ao Program to calculate sum & average of three Aateger numbers. chor, string) . Q3) Use a progsam jo demonstrate implicit dupecasting A eg? Wite a program to demonstrate explicit typecasting . as) Heite Oo Pregram AO demonstrate use of shift operator. ecsereeey : ; @1) Weite a program to demonstrate differen cost - ints byte. sho Yos } dupe cuse ati the types 8 wsheig c go boolean , 101g, double, Fioat char \s 9) Algorithm — Slep 1: stort Step-2 Declare aod initialize variables | of different datatypes ¢ byte, short, ini, long, Float, double, char , boslean| and sting). Step 9: Pini out the values ‘of each varicbles along with o desciplive lobe. Step 4: Slop. P L/Siop | ps aaa ai package assignments 5 public class progroms \ public static void moinGsvinglI args) A Int azide choare = 'k'; double d= 40.93 Stiing $3 =“ Pprerona", Beolean b= False; i float Ff =19.907, : Byle bl = 'a's Short st = SS y Object Obj =“ Desai oF"; System. ouliprintta C' Int type value ="+a)s Sysiem.out Ss er pruintlaC™ char tupe volue = "4 09; Gk prLoUaC™ Double type value ="“yq); System our piintinC” Shing type voltue ="4 $1), BY sien. oFt-prigtlAC " Boolean value = "4b);5 Sysiem.out-printlac” Float type volue ="4h); System. out pruntloc" Byte WPpe volue ="4b4; System. out. printIn(™” Short tyre value 4 st), System. oud-printlaC*Object Ape value ="4 obj); oulput — Iatr type value = b+ char lype volue = = double type value = 40-9 String type value= Prerana Boolean type Value = Fol se Floating type value = $9.30 Byie type value = 94+ Short ype value = BS Object type value = pesaioq. QD) write ai programy 4o calculate sum aad average of +three integer values. Algorithm ~ Step 4: Start Step 2 Declare tnree integer vasiebles arb and ec! step 8 2 Calculate ithe | sum a+b+c 6 step 4: the average av erage = sum Ay Step 5 : Pint sum and anerage. Siep ©. stop. Qram-— i package assignmenti AMPOrE java.util x; class programa public static woid main(stingl) args) t int abies Scanner Sc=new Sconnerl system.ia), System.out.printlat" Enter tnree integers’ a=se.neniniO; b=se.nediIntO; c= sc.nextInt0); iat sum= atb+ec, double average = sum/3; System-out-. pinuiac" Sum = "4 sum) ; ae Average ="4 averag Sc. closet); LC ti j Output — Enter three integers 10 20 B30 SUM = ¢€0 Average = 96 STEERER Sarre Qs) write a program 1 Oo demonstrate imp] a" 5 type casting: < Algorithm — Siep 1. Start Meclare variables of different \ dotaiypes int, long, float & double } step 3: ASSIGN Values to each variables. \ step a: Step 4: Perform operations iavolving these Variables 10 demonstrate implicit © ype casting, Step 5+ Print the resutis of the operations step ¢ . Stop. gram- Pockage assignment); public class programs public static void mainCstiagl) args) 4 ini i= \ooo; longi a tas Float f= 2k; double d= 2; c System out pridtIAC” Int value= "+ i)s System-oUt. printlac" Long value ="42h)5 System.ouk-printla C* Float value! 4), errr “Double vaolue="4+d); qe Output — Int volue = tooo ‘i Long volue = toco Float value = {.000 Double value = l-o000 (Q9 Ahi tyPpecasting . Alg orithm — Step it Step 2 step w step q: step sv Step 6: “program 10 demonstrate “i Stoct : Reclare variables of different datatypes double, long, float, int, shoit- Assign values to each vaxiable. Perform explicit typecasting +o Convert targee dotatypes to € Smaller ones. Phat the yesulls of the explicit Aype casting ©pecations. Stop. > Ce grom — : af package assignmenti; oe public class pragram4 ' t public static void maincstringlI args) t double a= 40.41) long 2 = Uong)ds floot fF = Cfloot) L; im i = Cintljy@s shor sz Cshori) i; System.out- priailaC® Double value="+d); system: out. printiat*loag Nalue ="+ 2); Systern. out-printlo C*Float value te qaatt System. out: pintiac” Short yalue="+4 5); em-out-printlac “Tat votue= "+ 0: 3 7 : Output — Double value = 8 40.4 long value = ao Floal vatue = 40.0 IonA value = qo Short value — 40 | (QS) Uteite a program Teva dlemonstra wae te waa" shiti operator. Algorihm — \ Step 1: stay i \ Step 2: Declare Lyte vosiables y% 2Y. \ Step 3: Assign the value to Lhe variables: Step 4: Perform teh shitt operation eax: using Ane '<' operoior, SLC P Si cc racns Maht shift operation on 'x! USing the sy ‘ operator. Step ©: perform zero Hu left Shift on'xX’ ing the 'sy> operator | Step Perform zero iit TIQhT shift on'y' using "SS 6pecator. step 8: Pint al lhe resulls ef each Shift opecatian, Step 4: Stop CZ gram - package A8Sigaments; publ ic class Programs Public gtatic void main sting(I args) { | Cutpat — byie xiy; X=lo; N= a0; SYslem.out.printin’® BilWise left SHITE. x >200;5 System. out: PLiatind "Bitwise zero fill left shift: ¥% ceo" 4+ Cx>?ay, System- Out printings Bitwise wero FI Hight shift: ¥ Dy 2t ye Cys>o); Bitwise left shift: x«xa a4qo Bilwise right shift: x2 = oe Bitwise zero TU left shite Eee = go Bilwise zeco Fill Fight shifl : Yspe — Cc, : 197324182). |) Aesignment. No. ob Name - Prerana Baltaso Desaj | tlass- acs- TL Sub: Java | Roll No-~ 6a Title- Contol statements [email protected])) White 0 progrom to toke | from ihe user and point | number . three aumbers the greater /a.2) \Weite a progrom to calculate factorias of given oumber. Q@-3) Wsite a program to print of given aumber. Q-4)) Wiite a program io display table fiorn 41 to 10 Qs) Write ao program to print is leap year or not- reverse mumber Multiplication ideas gu se es ee EE EEE GEESE given year i} | @4) White @ program ‘lo Lake three number Goa Trom Lhe .user and) point the greater aum{ Algorilhen - \ Steps ~ Start Sep 9 ='Read any -Lhiee mumbers as - Orb ong C \ Step 3- ifCarb @& aye) then Aisploy a is greater else {FC b>a && bye) then display pb {8 greater. else display c is greater Step 4 ~- COP: a O9.cOM Import gova. Uti} x + class GieolerNo public static void main( Stringl] args) { inl ob, 6; Scanner § =new Scanner(System. in); Sya lem. oul. priNUaAC" Enter three mumbers:") O= S.NexlIntO 5 b= g.nexylIate) ; C= s.nextInt0hs, ifCasb ©& arc) System.out.printin(a+ " is greater") elise ifC b>a 8& b>c) Syslem.out. printing b+" is greater’, clea Sy steM.out-println(e +" is Qreater "); | | | | 5. Output — Enter three numbers: Sa oe Fa Fo i8 greoter given number. Algorithm - Step 1 — Start t = ee o> White a program 40” calculote factorial Step2 — Deciore n,{ ond fact . Step 3— Read any umber Siep4- Appl) Condition as - foct=1 iy while Ci<=a) < fod = fac xi 5 jae Step5 - Display factorial of given pumber. Ssiep ¢- Stop - import java.util. * 5 class Factorial public static void main( stinglI args) | { | im 9, 03 | Noot facts Scannec Sa new Sconnec(system-io) ; System. out. prin (“Enter A"); n= 5-nextintO; : fortl=3; i=3; ponte ies n) foct = fact xi: ites 5 stam, our. printlo C* Facto rind =" 4 Fact )s 5 Lo Ourtp ot - Emter 5 Factorial = lao @3) brite a program to print reverse of given number. Algorithm— Step 1- Start Step 2- Read and display any aumber. Step 3- Apply condition as, while Cal= oj { d= ato; rev= rev «x lO+td; ito, J SteP4 —- Print reversed Number eee Stop. gram— import jove- Util. *s class ReverseNo public { 1 Output slatic void mainCstingl3 args) int A, ds cev= 0; Scanner s= new Scanner(Sysiem.-inds System. out. prinllac" Enter aay aumber:" N= GS.nextInto; while (n= 0) 4 d= d's. 0; fev= rev *10+d; N=o/10; j System.out printin( " Reversed Number "trev) a Enter any number: S34 Reversed Number aa5. else > 4 Leis System. out. printla C*Element "+ element [ls Found ot position: "+ pos), a public static void moin( string LI .args)_ stock< Integer) stock=.new: stock icintege re C5 Stock- push (stack); ; Ebi t ote slack pop C stack); : stock_push (stock); Stack peekCstack)s. stack_ Ssearchc stack ds . Stack_'searchCétack, ¢ 4 } persicae s Oulpl- POP operation Oonpwof Element On! Stock is ef tals «maday Element 2 ‘is “found at position . - ‘Element Gig mot Jpuggt 750s - 2QgraM — lass Muttiplication oO 0 public Static void maint Sting [1 args) { . int ists for(jai3s ik=t05 f44 facW=1, dc=10 5 d+) System.sut-primiCixj +°) “Da 5 Syolem.out-piniO; 2 ae Soe + se sf 9 So Se ko SS Sy oe oF Bo 4 S (2 \6 20 24 2g 32 36 40 3.0 5 2> 25 So 35 40 46 50 G2 18 2¢ go 36 42 ds 64 Co Ge 21 2a a5 42 80 Se «3 to, @ \6 24 22 ao 48 68 64 32 Be Ss Boy ac 45 5¢ ca Fa 8! 9° Jo 20 go ae se 6° 30 80 90 3400 - | | year or not \ Algorithm = Slep 3- start Step 2- Read any number as year . Siep 3- jifCyears.q2=0) dhen display year is leap yeo else display year is not leap year. Sieep 4 - Stop. Fl ral 4 mpoat javo.util.%; class Year: A parbic static void main Csting[] args) a int year; Scanner gs = new Scanner(dystem.-in); System. oud -prindinC™ Enter year ="; yeac=cg.nexiiatd; Syot fC year % 4 == 0) System.out-println€ year+ "is a leap year "y, _2ise oa System. OLE. Printlo Cyear 4 “is net } a leap yeas ‘D5 Output — Enter yeas 2016 2016 is a leap year. oe ye es Assignment No.3 Name: Preranq Balaso Pesai Rollno: 58 Sub. Java Title : class , Varlables and methods. Qs)| WWsiie A Program Ao display student infor- mation using student information and marks | by adding calculote method. j— jan) lusite a program +0 display prime numbers | ia given cange Using “(sPrime” method . method, | ———— | | 4) ite a program to demonstrate use of betnis’ keyword, 2 QS)| \drite o program to demonGtrate SWiNg class methods - @3) | Write a Program to demonstrate finalize | @s)| waite a program to accept a string and uhether the string is palindrom cr not. QI) write a progeam to marion Using student marks by addiag Bre Algorithm "SLEP Acie display coJcutate method. Student ing la foermation and clas { Start Step a Create class student . Declare rolino, nome, marks of three subjectS as mi, ma,m3. step 3: Create methods and @zite the | Particular definition . Step 4: Calutate total and percentage. then display student information. step S: reate second clasg then unite | mata method withia it 5 Create object of main class and then cal) Stop- the methods.- class Student jat collao ; String name 5 void getdato Cint rno , Sting am) t rollno = rao; name = nm; system out. printla('RoVao="+ rolino + 5 "Names "4 name); Wat sip 62) S35 void calculateCiant ms, int m2, int m3) { $1 = $2 = m2 63 = m3; int total = 63+ s24+ 93; float. per= total /3 5; system. out: printin(” Peccentage = "+per); } S class Studiafo" { | | | Public static void mainc string argstJj) Student 8s= new student ); “g.getdatalios,” Prerna"); g. calewate (80.80 ,80); SE . ae ——— amet Poet gO | oOutput— Rollno = Jos nome= aaa Recetas = 80-90 : os aes waplay prime numb | leon lusite a Program aig Prime" enethod- = | in given range usios \ | Rigarithm — | Step 1: Stark siep a: create clas9g- Siep 3% Dedare min volue and mox value for range and initialize AS- min=2 and moex=ioo Suelo ae. Hee Re a on if C isPrime cn) ‘ Fcink 17 cin 3 i Step. ce . - G i i< am Jia it Caum 7.j) ==0) { retucn False; s $ return true. Step 6: SioP- rogram — lass Program static void main( string argstI) public 4 int min=oa, jot max =1003 for Cintm= Mins nN <=mMoax ; A+++) { if CisPrime cod) LO { System.oul: Printlatn) ; 5 + 5 Publie Siatic boolean isPrime Ciat aun) foccint i=a3 icsaum/is j++) 4 == 0) aoe Joy i: retucn false, A $ cetucn true; Output — eS) So 13 14 19 393 oo a 4\ 43 47 53 59 61 64 Fl 33 34g 5 3H. 37 893 | | } | @ay weite a program 4o aemy: method + Algorithm = siep 1: start step 2: create a class stop 3: create an object of that clase Print objy hashCodedd pre siep 4: 7 defined method hashCode which 1s siep S: Then initialize first, obj= null then Susiem.gce- and then print end of garbage | collection. Step 6; Declare finalizeQ method. siep Wt isplay Finalize method called Siep &:(Stop.- ani: y eae rogram - tKloss Proqvam 3 public atorie Void marncstring 9¢gsf 1) Rograma P= New ProgramI(); System- oud: Praia Pe. hashCod eg); P=nwls Sysiem gc; System .ouk- priatlnc Lod of garbage collection"); @ override Protected void Finalizecd System. out: priatlac" Finalize method calted"), 925856445 End of garbage collection. ea gemonstrate USe g Qa) wile a wanis" Keyword - program v0 Alagorithm— Silep1 i start of type \ateg to siep 22 Declare a ond b step 3: Use parameterized cons tncto¢ imarolize a,, and h-. uslag “Uhiis Key word. Slep 4: Display a and b- Silep S$: Stop. A A [ Program— lass Program 4 \ jat as iat bs Prgram4 Ciatia, int b) i this.a=ays this .b=b; 4 i void aAisplay () Syotem.out-printlaC*a="4+a4 “b= “4b); J Public static | void main CStiag argstl) 5 geet pear Parag Pi= neo Program 4 (elo ,209, obje P. display, 2 i G oc i} a0. aes PCPS 1&s) bite a progr demonol col Vas) White a program 10 | dass merhods - | i. | } Algorithm - 5 | Svep a: stadt oa SrteP 22 Cseote ihcee stings as and sa. Step 3: Again take anothec sting as s Sleep 4: display s Perform as sting - ; StANg Methods of Sting s S- Lengthy) $s. toUpperca sey , S-toloWercaset), «. trime) . | Step SS: other Methods | Prefie «8 Sapte Concat the Display s as Nee Ais play f ef sting. tWO Strings . _9s5 Using S-replace other methods 1S. substing » &8 $0 on, step 6: Stop . ( public static void main¢Striag argst)) class Programs Sting sis “Tava"; chac chTJ= {'s'.’ Sting s2= new String ch); shing s3 = new Sting Coriginal Sysiem.out-priatlac™ Assingniang swing wheo declaring NKe variables="453); System.out: PriAtINC" Creating object of sting elass 8 passing character aray-452) object of striag Pitan e's} y "example"), System. our. printla(" creating class & pass Stiing directly="+ 83), sting Ss ="kasturbaj Walchand college", System. out? PriiatlaC “Orig inal stiing="49); SyStem.our-printlac® Length of sting= ‘4s. length System. ouk- Printinc’ Uppercase steiag =" yp s.to Uppercase C)); system. ouk-printlaC" Lowercase sting = Va s-loLowercasec)); system. out- Pra ("Remo ving extra spaces =" + s.trienc)); System. OUt- pI MIAC s - Starts With Cpreny * "ko") System.out. pri atlas - ends KLth Gsurpix + “en; System. out prinlla CS. Concaic str: “sSangli i System. ot: printlo C eo Clacget: “Cotte, 2 75 ‘9 Sa a replac S\Nag replace stu age sr eR ee coplacerne nd = cones ; i a SLO b Suastemcoud: prigtindreploce at 9 an a.sutath Suysters. our. pyiatia Cl Bub Stiag= Cheginlodes % 14 ys aoe 1 ae -su lo Suslem.oul-prialin(" sub Steiag = “+s -S seeing Cheginindex +10, endin : Ne System. oud: pri ndlac “connected string =" + striag, doin Cdelimiter =" 4) elements --. } “Jova", “ progracn ),; Output - | Assigning String when decasing tite variable=java Creating object of sting class ® passing character array = siving. 4 Creating object of iri Aleectly = example. original strings casturcbaj Length of sting 33 Uppercase strind= (g class @ pass sting Kalchand college KAsTOR BAL WALCHAND COLLEGE lowercase sting= kasturbai awbichand college Removing extra spacesa Kkastur bod klalchand College | false : folse kasturbal klalchand College , Sanglj kasturbat kKolchaad college Sub Sting = alehand College Sub string = rabai Connected Stting= gava- Progsam . 3 yoeite G PrOgKe ainethar the stsiog BEOABS Filgorithen — omer a oting ard is Palindeme @B mA. FAGR 4: Blast Glee a cseake class Step a: dedasce bls ond sey. Slep 4; Pead any 4ising from user- Siep S$: Caluwate length of sting at, int length = str-lengihc) step €: ferCini i= lengit-3, frre, j-+3 ' { 5 Siep 3+ if Cste-equats ccey) — then print “Sting is palindrome” aise : Print = String feu rey + ste-chachi@; is not palindrome Step 2: stop. spteeneenneccl eta eOe pee nrnrenemanresenrtntnen oe - | import Fava.utit. scanner; | Public class Programé RE partic static Void main (sting agstD x Scanner sce = mew Scanner csystem. (9+ Sting str, reve" 45 Syslem.out.priatia "Eater q sting: "); ste = gc.nexiO; Tat leagih = st. length o,; for Clot t= Vength-1 3 te=0 4 j-53 4 | ; rev = rev y ett. Chara cid; } ifCstr. equals Ceev>) Sagstem out: printt(ac Sting is palindtome'), 7 else System. out printtnC’ sirlag is not paliadeo- j 3 Sc. elgseo ; t it Output—- Enter aq string ; racecar sting is Palindrome ae Name - Clase- Bos-m Rollno- 58 las \@.) @.3) —Assigament. No. o4 Prerana Balaso Desai Sub: Java. renee anata rages Ca Title- Overlo ading? write o Program +0 overload Method by Passing different number of Parameters . Write ai program to cadcwlate tfiongle, teetangle 8 overloading. avreq of circle Using medhod see Wivite a program to Perform oddition operation various number of arguments to determonstraie use of default , parameterized & Overloaded constructor, Ql) Lite a progeom 40 overload method by 00%° Passing different number of Patometons. 08 Algosithm - ah step 7: start ah step 21 Display method with single \ “axgument: 1-e. VOid displayCint cd | | Step 3: DOisploy method with two arguments ' be. void disployCint c, int que) Step 4: Display method with Ahree arguments| je. Void disployCintc,int num, Wnt PP). age can all the method by using of obsect class & dot member-— ship operator. Step 6: stop: 8Qram-— lass Test i L public void display Cint c) t Susterm.out-Pprintln(* Method with 4 porameter t te). $ Public void Aisplaydint ¢. int num) System.cut PINUAC” Method with 2 Parameter: 4 eae se num); public void displayCint co int aem, int susterm- out printin€ "Method with 3 parametee: ee Fee 5 | 3 ctass PLY Public s¥xtic void maint striag argslI) [3 Test obj =new Testo; obj. display C10); Obj. display C20, 30): obj. display (40,50,.6e); i Output - Method with 1 parametec = io MNethod with o Parameter = 20 30 Methed with 3 parameter = 4050 co @2) Kile a program ‘lo cateal ale area eA Aiangle , rectangle & clrele Using methag| ovedoadiag . Al\gorithm - Gtept £ Start step 2 2 Print Mrea of square by using weiey formua as - Moth. pow CX+2) . io | Tiest function definition. ee. areaCMool vx) - " t+ Prink area of rectangle by Using Toma ag _ step 3 Roxy in 2 second FENCAION definition. he. area€ Flool 2. float y). step 4: Print area of the circle’ bY Using oemMa as : Blt * Bex RK- INQ Bed. Aunction definvlion . ie. Qreac double &). etep 5: Cail all the ftenction using object of class and dot member- shie operator. step G6: Stop. Fag ' LOGO MY pablle class Pa ¢ ' paublle static vole { malaG string fy. args) Caleutatedvea ole ob. Are aca; Ob. area CIO, 9); Ob. avea C5. By New Caleularle Aecac); \ class Calculate nrea void area C Mock x) Systemeoutl priauine" The area of square Vou atmath-powlx%,20+" \ : “sq units"); | Void area Coat x, Moat y) | Mees teecl paraUin Gane Gee (a recterale (er | +X" Y +" sq units"); void area Cdouble %) { double x= 3.4% x x XK} System oat printa OC The area of the circle \ ig "424 “sq unlis"); output — The atea of the square is 36.0 59 untis The asceq ef the reclangle is 190.6 sq units The area of the circle is q4.495 sq units. z —— —— perform eddition op, G2) tinide 0 PprogromMm £ arguments to ation vorigus number °° 4, porameterized ements use of deioula, oveWooded condtiuclor - i Bigorithen - ; Step 1: Stort step 2: 3nidiadize value by using defautt consisuctor - ond print then- fAePp 2: IAnitiatize value by Using porame- desized constructor by passing single Vaxioble. eod Gisplay them. eti]ep 4: 3niliclize values by Using pasamete- «med constturctec by passing so ergument end display them. siep Create object foe each constructor . ond ca the displayc ) method. siep Gt Stop- Jogram— Lia SS DemoClass { iat. vali. vata, NNO argument constructor VDemoclassC iat aum4t) t vall= Jo; vain = 20; Sysiem.out printin” Democlass : NO conateuctor Ds avg ament $ I/ overloaded constructor DemoclassCiat anums) | | | Py ns va\o ane syst Gut-printhac”™ Democtas >! Ove cloaded } constructor with one asgument"); i DemoCla ssCint nam, tot num | t vali = num; vaja=numr; System .oat- printing "DemoClass: Overtdaded| Constructor with 4wo as guments),; 5 public void displeyo System. out. printinG "Vals “4vats + “va” } +vala); class P3 os 7 1 TQS pablic slatic void mainCsidngl] args) ‘ Demociass dl = new oemollass©)# di display; Demo€lass daanew DemoClas sl!» 2. displayed; DemoClass d3shew DOemoCclas s (20.40); AB. displayO: | Output — Democtass: No argument constructor vali=310 volo = pemoClass: Ov€rlooded coqetmctor with one | Argument vate = 70 | Oemo Class ; overloaded constructos with | orguments . voli = 20 valt=do. Cla sS- BcS-TT | Tithe “Java.” Sub: \ - - : 1@4). bide a. programisi to, display Upper and | lower tviangular omabix- (Qa Wsite oa program to, Enow that? whether an array is arranged in decreasing oder or, not.isiiet persis my _ (a3) pite a | program; to, pass argu to method - : i @a> kitite a Jova program, to ,remove, .:a specific element from an arvoy, eee - = iC was Waite a program to display oppes ond \ Lower wiangulasy martriee- Algorithm — stept 3: Start Step 2: Declare a class named Qi. Step 3: For lower triangular matrix, we chec the index position j sandi. ie Tow and column resp. If column position tS Gseater than row position we simp make that: positicd oO. ‘Step 4: For upper tsdiangular matrix), we! check the index position 1 24. j-e. row and column position iS “Srhalter than row on we Simply make thai ‘position Cc Step 'S: Print the’ péesati 2 oo Sleep 6: Stop. I ———_——_—— Oo gram— Mport java. uti x ablic class @Qa public static void moaingintmMatixCintCIlI arr) L int me arr.length, iat n= alr Cc length; forcint i=05 jem; [++) PPOKCINE, GEOR Seay +40 | Syustem.out- printc arclil[jJ+ " "Ds i | $ eee \ System.out printhacys on j a oe 7 4 public void lowerTriangular Matix Cint orrlIl inticomsarrlengt int ace.arirloJ. length ; iid A eae UF Cen [om System .out-printlnC” Matix eniered should be a Sduare matrix", + System. out. printlo C' Teg Seale retucn; oe. : | t | hee | © pocciat isos femy HES SF forCintji=o; d 1 : | seth ' Syslem.our. printing "Lower Tiangular Matiz, les"), PrintMatrty cad; eat aaa 5 } Le Triangusidr Matcleciat anCIlI) public totic void mnateeTsliert ys” args) inl m= arr.length; int n= arre[LoJ.length; ifcm!} =n) { Systew/dUA/priiatla C" Matix entleredl ehould be ae A SQuOKe Matix; 6) System. oud. printa CMT ay jagain..")5! et return ; Cries gre} - else tne xuboetl SIritotiq- bug. rasteye | t ‘Poe CAN OF lems ie ForCint Jso; deni J+ 1 Ie Cia) arsCiJ LSI + 0;,,.; i Susiem. oUt pid aC print Matix Cor); ] ublic static void moinc stingl J args) Scanner sc= new Sconnercsystem.in) ; int min; System. out. printinc “Entec the Number, of cows:") M= Se.nextIai cr, * : a System. our. printing” Enies the number OF columns. N= sc-nerntT are System-out. ptintl ater the: ervatrix ‘elemeni's:” int arCILI spew ed aaa ea forCinti=zos i 3 # 5 € F864, ve i 2 3 rt Ss eR 3 q 22 a Sti ginal “Matix is: 9! vee ee , ti net > <— = ee i 2 B 4 Oddo Viana. CRU Ci I tea” Lower TriangWot matix is: i aL S| oO init yp teocrss I Tors , + S © oe ei Orrell 9 es Sexy oat 3 80 : 2 : tah 19 SL FAi + Orsiginad mowmie is r L 2 3 Diba eo eo : 3 8 4 rite cee al ‘ pper Tsiangular matix je: eS ° 5 6 Grog By write .a program 10° know, thet whether an array is arranged in desceeasing oder ED Nok - Algorithm — i i ; siep 4: Start Step 2: Declare ‘a class Komed an! siep 8: Declare and initialize an array. Step 4: Loop through +the array and select -a9 element- a ; i step S: Imnec loop iN pe. used -+0°' compare Selected Sfement “Rom cul iddp with ceGh oF the elements ofan array’, step 6: Tf any elementis greater than the i selected element then swap the values. | Step tr Continue. this; process’ + 4i\t entire list is | ip Sorted as io -descending oxder. step 8: Print the! iResulilt Step G9: stop. Dive Hitikeq «F119 eas aot

You might also like