0% found this document useful (0 votes)
4 views

Sreelakshmi Java

java

Uploaded by

sreedevi v
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
4 views

Sreelakshmi Java

java

Uploaded by

sreedevi v
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
Aaa ee ey en 1) Jive Program 4p Add—two Integers S Class Main £ Public Stedic vold main ( string LI args) i Int first = lo}, Ink Sewond =20' ]/ ada-lLw0 numnbeys Int Sum = fixst+ Second } System. ouk. porn Eln Cfivset Na hy Second + "="4 Suny; 4 Enter 400 numbers lO, 320 The Sum UD 2) To vompute Quoblenk and Remainder Public » class Quobent Remainder L Public state, vord main Csting CI angs) int dividend =25, aivisor =4> int Quobient = aividenad | Alvi sor 5 ine vemaindeye Alvicdend °lo Aivisor; Sys tem. Ouk. print In (Quotient a+ qGuobenk), eee Sys bern - Out pont In ( Qornaindel ="+ Yemal by n y pat Quobonte=6 Remainder =| 3) To Swap to Numbers . Public class SwapNumbers § Publ'c Stale void mak, oan (stony CD em gs f Flock fxst= |.20F Seund =2.45f: wD. System Out print Syst ern out . pr! im - Oud pnintlo (" Strond number = "+ %ond)) fl value of First $ assrgned to temporary float lemPpovary = first; I] value. of Second 1s assigned tv Arst first ~Seconds I} Value of bompo rorry (which Contains the Value of First DIS assigned bp Serena Setond Feroporary; initial System .ouk epyintln Cl__ after swap __")s prot In C' first number= “+ frst) 3 print In ("S€tond number ="+ Setond); Swop—— at NUombel 1-2 eonch pumbea = 2:45 -- Aft Susop— = Fivst number = 2:45 Sond number = 1+ ee A check whethec a) pumpber Se eG using. if else Statement: Inoport Jova. ut! Sta nner’, Public class Evenodd f Public Seite void main CShing LI args ) { Scanner Tader= new Stanney Csystem.in); | System. out. pink (Wenter a purmbe .”)5 2 Int Mum = Yeadey. next int); tf (num ly 2= iy) System Out: Print InCoum +" js even"): else System Out print In (num "iS oaayy: é Oulpat Enter & number | 12. oe 12. ts een. fna the largest among Ty ts on d 58 $ Public PUblic Stair ! double ni= -45 tf (wl >=n2 ¢¢nl> =04) Systema out. pontln (ni+' is the lasgest nuroloes .") 3 else If (n2> =n] ¢ € n2s=n3) Syste .Oub . paint In (m2 +" 16 the (deg est puen ber") > else Systtm . out. print |n (na +¢tis the lacgest.) the (arg est Duwmbet Pc) To check Wop yeas i Publia class Mafn § Publi State void main CShing be orgs) f (yeoa fo be” Cheeked| ] int (Gears 1900; ! boolean leop= false 5 Se EEE IF the Yoo iy divided by 4 pe Cygens Plo + 220) § aM the your is Contry if (yeas leo #20) g plf yea ts ciuicled by YOO if then Ie is & Lecp yoor if (yeas elo 400==0) leep tue 5 ele leope False 4 fl if the Gear ie moe a elie tty leepe hue, 5 elle leop= false, if Cleep) System. ove. prs on Phot Cyeae 4 Nisley System. out - Pant} nC p ‘Oy aN hy ae : aceon); 1 OubLpe. I400 ts mot & leep year 4) TO check Uhethn a number is tue or -ve. Public. class Publis Stale void main Csiving LD cays) § double number = 12.35 i] true (fs puenbey 15 ten. eee (£ Chumber 20 oD Syste . out. pratln Cnumbert is a beg abve Dumber.) 5 [] tree HF Punber tS greeter them 0 else if ( pumbet > 0.0) System. ov printhn Goumbey +! 1s & tue umber") 5 Nid both ust 2xpyesion iS

You might also like