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

Java Assignment 1

Java assignment
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)
20 views

Java Assignment 1

Java assignment
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
You are on page 1/ 14
—Assignment-4_ plete a Java eb ageace tn iG ict nel re aan, I — "hello. Tava." onscreen, =|class_Hellojava phoats de ie i | i zi |; Public_static void main(String flargs) |_| i - System.-out- printin ("hella Java")j _____] 4 Output neti Javae Lt2t5+44¢5t+6 $2 +0. = Liiport java-utile Scanner 5 publi lass i" : i 5 \ | __ public static “yoid. main ( Stringllargs) = | ——+ zs : i fF | __int sum = — ? * ne 7 __ system -ouk-printia C Enter abe Be: Scanner ac = new scanner (System-in)5— int_dum = Sc-next ink (Ys; ak (ois jody i$= que 5 i++) —___— Write o javo 50 numbers« Lyons : | |bek ae Enter the our. sum —oF numbers '-5.5. output = pragram. to print_the Bisa ee _ — __} seHes: up. Po) lass Fibonacci — _ = at ae het — public static _vaid _rain. (string tl 2195) }—__4— ee ca | Sie int a = 50. First Term =o. Eecond ter, . ~ System aut printin L’ Fibonacci Series eS ey | = meee De J to", _—— [shite fits bTeren <= a) — —_— a =. ff ~ = $$ _System-out-printin (First Term + Bey et is of : —— | int next Term > FirstTerm + second Term; te | | einstTerm + second Term — _ second Term =~ next Tetm 5 Fibonacci Seties Upto Sa ag eee Re i oy 4 ©. Aumbet ar _not- import java - util scan Class_Prime Oo. jaya. $$ Program _to_check whether +he-— Public Static void main ( String £1 ar. x. a Scanner _sc= new Scanner (system-in) > int number = 5c mextint (5 i€ Cis Prione (number )) H ie (num <21) ae F i + petuen Pale i itt) for (int iz 9, i<= oum/2 5 itt t - \ je ( (oun t= sO petuen Palse 5) 0 \ bf - \ __teturn rue, + — Output Enter +he OQumber: 15 45 iS a Man- PHME Humbe, - I r | 5 | Write o jave..program. to_display even and 9, | numbers C.140.100) and_sum.oF odd_ang 9," “f F |.no. — | import java util. scanner 5 \ + class.Java. tr E + $id = E E —— public static void main (Stting Largs) e L dese =. | Scanner in = mew scanner Balan io); Pap ecu =a _asum = 054 ee p—$$_} system coub: printiy (4 Pe tec: a For (int i= 15 je=too, j++ a | ot : eS ane ifiaes wn). — eS mae t : _ {____ System. out: ptintin i++); ~ —__eSum_ += i; ih t } = aay ; = ——}—_|__System: aut printin. ("4110 100 add avmbel, Wo jj —— Fok link ist 3 ies too» i++) geet ad . 0 lS Se hopeo). 4 phos — ki io eras —_ Se: System out: printla (+1)5 = SOSum bey | | Output - System. -ou2: printin (cum ae 44a 100 even | _ Mo_= + even.) 5 System: aut. printint” sumine t10 pan adit i noi" + asum); — t -Lt0_100 even mois __ Od Ge Bi, 10,19 46 16, 28, Y 20.22.24 26.28.3059 . a 6: 7 5 ; | —> import java.util. Scanner 5 public class SumodFdigits. i 5 bis f | _public_static_vaid main(String Cla+gs) — “Ted pihile_(oumber?-2) t 2 4 = _numbert- 105—— digi sum_= Sum_t digits + number -=-number (40.4 j = gumn_of digits :", + 5. fm System.out- printin (” | bribe & java. pragrand an he ee my Mae. EE 1g _palindrame— Gsepiade seed to +t java util. Scanneb }——____ } S; | public class palindtome —____ _ h 4 Auli tic voi i a : aid main | String [Jargs) | Scannet_in = neu) Scannet (System in), | _ System out print (" Enter a number :*}, | | ineowectarenextinb (yy) sea Int sum = 0,4; ary ides sum_= (Suen * 10) +h5. = N= A/104 | ink temp = n+ | pfs scltbile Winpodicy io —_ : | a E cee —| = = [ LR } a ci —S = \ i att a Tava. program +0 check whether the. | B= ilkite Number is Perfect Oumbst—ar oot -— > | import fava. util. scannet ; | class Perfect — ii = public static vaid main ( String [}.atgs) nts Beaala Pestaay pe int aes __numbek")i Outps i on Gis a Perfect Oumbetr __ B mle ee aeteare +o Find the Puinbatls OF ahd a of ali integers greater than SQ _and_less 44, | 150 that ore divisible by —3-—— f | Public class SumCountDivisible £ pS = Public Static void main ( String 1 a+95) he sum of the number © 59 +o 150 which’ SySiemoaut.printin.L” Tatal qumbets betiued So +0150 which dre\ which re divisible by 3 iS: 226% Total Aumber bet" So +0 150 Which dre ___| _ Hist by ae divisible by 3 is t count), AS bf The_sum of the number bet So and1sa. as | Jj 40] pide o java Program to le URY thee Sindy ed _Triang| 4 a — ts = = fin 425 =. = k = fee es — | public class Patternt af i _ public static void main ( S++ agiia.gs) — ae {a = | ink tj eae 7 _/Lloop For rauws t PF fowt ceo penis renee = ie j povet ee: | | __numbet = 15 soe 4 | loop For columns — = = for (i095 jani, itt) - L ee E elas Ut prints qum — print Lnumber-+ | System out ing_-the value of num bet 4 iocrement number ++, 4 throws +he—¢ printing each row 2 Yeoman et system, ~ out eer ae ursar—at the 92x¢ line ge, a. tblic lass eon eearoain ie = Bd ee f J —— — = | =. id_mnain( String £1 aise) : | + (poe 1 [ | Bet feng ji r rn ela fe | . : i rf = ee Gut. printin(" Sum =" + sum); = /_ Output — ame ae 2 ay : | —12.{ brite a pragiam to assume. -aF employee in a _company.,also_assumed } that three categories of employees dre sa —}+——} Ptovided allowance a+ three different bates. — Determine the allowance tate for am _emnpic:| + —}yte on the pbasis_of his_categary The _—_} —_} atlawance ig dhe Computed Callawance = incor —_}—_—_|* allowance _ rate) me = | —* (import java- util scanpek >] lass lava ____— ep harAt Co); out print C layee. | | | System. out. print ( Entek eenp —— ! & Income"); a Ri q Jars | else ie emplayee—cated oe po tabegory— ea 7 a ail allowance. = iacame * allowance Rate , | = SS aE as else if (employee category — <" ll eraptoge| E- fi paar lb: ___cate gor: +c de a _ [— me ee —— pate Ne | allowance = income # allowance ~ Rate ¢. | & (i= ee ee ait J) See ne “system cub: printla (Zoualid empiagee cals.| gory > Please entat A.B arc), a ee eee =, i ft feturn 5 — mt ea i L f eg J | system. out print C the allowance For the 2 _emplayee in_categaty Ae 1S. 5.) 2£ }- employee Categary allowance); Scaqnnet . clase () 5 _ = — fs a 7 = te ys, a | i a ee Jot ite o& Progtam +o convert decimal numbtt— ~~ — { | into binary eS = | public class _D ecima| ToBinary Fxample L | Z ‘a — public static void main ( String £7 9495) . - LSS EE at esters Out. puintin ( Toieges +0 Binary Strit of Cosy); Joh ‘i Se MerdlirA pile (degen ite Binoy Shui i eae oe ee Eee JI asia Beis Sy ties ie Sana = | Qutput = = 1O1o 10101 | oeiede = 44] Mpite (Sh ee pe | Tatetest and Compound Tatere = t — | import java util: Scanner 5 class Main me void. main | Sting t1a+g5)—(—— \ a create an alias oF Scanner est ee eet print ( Eoieh_the_puincipal}5} TET dunt aa - | Scannet input = new scannek (Sys one! input Prom users. = input next Double C) ~~ nm eaten Taras oe —— ae ippuk next Double) ja ie je ipuardnboe( ptiosipal Stine tat) asais5 fe = pkin (2 Principal."+ pring. daub | System out pki slemaub-_prindlo.ttnkerest Rate+ ph, Sy: a “System out printla C Time Duration + Lima uke AimliaLs simple Interest :” + = = intebest); Paces ae pt 4 $—_— payee (| Outpub= +—Enter— Enter the rate 2 15 + Enter the time; 2 Principal: 11-0 Interest Rate : 15-0 i Enyce:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy