[Go to site: main page, start]

0% found this document useful (0 votes)
2 views17 pages

Java Note From Array

The document appears to be a collection of code snippets and programming concepts related to various mathematical and string manipulation functions. It includes references to abundant numbers, automorphic numbers, Fibonacci sequences, palindromes, and pangrams, among others. The content is fragmented and lacks coherent structure, making it difficult to extract a unified theme.

Uploaded by

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

Java Note From Array

The document appears to be a collection of code snippets and programming concepts related to various mathematical and string manipulation functions. It includes references to abundant numbers, automorphic numbers, Fibonacci sequences, palindromes, and pangrams, among others. The content is fragmented and lacks coherent structure, making it difficult to extract a unified theme.

Uploaded by

shrikavya2004
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Abundant numbey

ehoud be
excet that nwnbey
of the humbeus
lba ubn ot actor
Psint ){
greater than that numb .

th 2, 3,'4, 6
loaving 12

the
i+t) jen
ij4 a=
tJe;mp ; temp
a[)J

and
aunay ieD )ritl ; )
Peutect num bey

Addì tiOn of
:
the -factors of the numbes e t
be eq ual to

that humbel.
the }

0
tint
sort Cint i

tor
5
3

G
for ÞeutecE Aun beu
abundant numbe.
>0)
nt U; Sum
Int n
=$heatDnt t) Int n -s-hert

uhdant
S-o.p ( ' AB

j+){ break eue

fnireopntaihg cSaodeme
ijen
not abunda
j=o abundat
(int )lb

Petect O
tor
the b4 t e no Shold
Auto moYphic bp
bn tain the' Same no Ambtnng num ben n um br
the digik ef fhe given
45 =b 25 Gtum o+ the POwey of
Þubie lass Main S Such au
args)
main (sting =i (noo. drgi = 3)
Publie statie void j 4 59 3 = 5 3

in) : 153
Ecanner new Seanne (syetem . 25 5 = 5 ( e . ot. digits = 1).
(0 d=lly m=n;
Int n s hex Tnt

while (h >0) Auto mophie Fub Le las Amu rong f


pubie &tatic void main l ing [3 Qrgs){
d=l0 d=40 & hew &anDer
taystem. in);
Scanher
nt z next Tntc) , M=n, 0uht'0

Wwhile Cn >o) I53

S-0.p ( Attos no ) ; Amatong NO


Auto morphie
COunttt

ele
Automorphic
while tn >o)

Power ot a numbey

G without wsing inbuitt


Publie class mein f
Publie &tate vold main (Sting II args)
in);
Stanner s new Stanher lLystem. j
b [Link] Dnt t), es ult
Iht R &. hekt Dntl)

es wt 4;

( Sum m)
elie
cmaller than Previous ( based on printing) i
fbonacci teu m

Publie elass ibonaceitemf he Inpt for the aTray .


main (sting CI ags) ? get
void
pubtie Statie
(yatem. in);
-for Cint i 0 ; len ; it+)f &9 7 9 5 2

Sanney 4 =Dew lcnner last|,te mp


o,
Dht C) , fist
MAY

-f-hext
Int h a LoJ ;
izh-!3 1++){
Hri4 + Last;. 5:ot1 23) for (int i=0; wmpaig
temp
-fist laut 3.
faat = temp
7%9

2. 0-p (int); 5 > 2 2 s wA


t
. Rext heade ony word
strng ’ caus in java. white Spaee ats0.
" RLtLne ead
altern ate Corting tmmutable.

8orting amay lyntax A+ indy )


net O. char
ien, it+) har e = Intormaiori Interchange
tor (int i z0 ; Ameican
Standaud
code for

ALeIl characbes
Gwhen mathehnatict is appied b[w
help o+ jaVa - then autoMatically the alphaber
Print A-z with
Înoemented.
temp = aCiJs
a Cjl3 er ehar ca'a'; ces'>ye t+)f
a[iJ

t
12 3 4 5

5 04 2 3

ìnt K 0
atenate

i h j it+)
tor (int iz0; Sortig
Q4-07- 25

n0-of-charater in gting eapt white space


ubie das chaunstr $
Pubüe tatie void main (string CJ args) {
leo wt)
&eanner &e hew laner ([Link])j

Int c0cnt 0
(mon4 whit tüng:
nsohants in
tor tint i =0; iz sr. lenqth ) itt){ LOLunt

ehangei
Came tod with
lowht+t;

&-o-pcount);
Swetha

t-0p Co wnt);

Opun and cose brack or 'arraye


tength C) onty tor string. teng th o sting
Swetia gir gth );
2
Publie sfatie vold main (&tring ly arga) tDnt nam bous in a 2tring:
Soanner & new tanner system- in); Pubue cass ns-otnumutr
main (sting lI arg) Swethal23
wnrei nto Pus e static void
chauatte4
Stanner 2 > hew
Sean her (Sytem In);
auuay char n nextitet);

har cC3 . to lCharAay 0}


int ownt e 0j

tor tintlz0i ie e- length;44)


&Ine wnt is 4 .
-bf. word in Sting
plbue lau woYdyuting
8-o-p (eunt); (ning C] asgs)
tubie Stabic void main Hii Swetha
CPystem: in)3

reuse
Pubae lass reeting
(sling lT arqs) Swetha
Pubue &tatie void main
n)3 aht ew.
Btanner s new Slan ner (system.

Sting
tengthC)y i+J.
tor (int iz 0, ;. i ctr.
t3tr tr. CharA t ) + st

word.:
4-0p (ntr); Length ot Last
Pubie cas lenotastwordf Swetha
] args)}: 6.
(string
Pusie statie void main (System. in); i am giri
SAting patndrome : Seanneu 2 naw scanne
Publle das sing chartray O;
Þublee atatie void main tha c3 = 4tr. to
/p C);
Beanneu & = hew Seanner syttem-in ; Int count=0 }'n =[Link]
Palind oMe

char e [J : &,. to Cha tray ;


or tinti0; iz nh3 it+)
[n-1-i3)5
Reveue word in 3+N19 t-length
2sb
8chool
Pusie elass Reveucvordf
(Sing I7 args)f
Pubue sHatie vold Main tn);
new eanner (system-

string frell). z 0j

wod [Link] (i);


Duplicate only 3
Bup S [] args)
Publie las (Stni ng
else void main
pubue sbutic
Snney S
Seoinn er
hew Cytem gehool
nextLine t);
String &i CherAinay Wj
chur erJ S1. to
['56J;
3 =. hew nt
()} it+)f
Jor (int i= 0; ic s| length

Ceurente of element in stning s


O
jt+)f
S- lengthlU
Public clas elemens tr lint j =0 ; )4
Publie stabie vold nain (string CT
aq) $
Stanner e new Sianney (System in);
tnegrn;
Sting str 9- RLXtLine t)s
thar c J tr."Char ray )
> new int (s6J;

C-length
Print noh dupieate to Roi way timo
on veion
igular

Þubie el ass NonDu convewsion f


(ring l) Qgs) Publie elass railway args) f
PUblie statie Veid main main (ring []
.in); pubtit stati e void (cystem in );
01:05 49 Ar
3lanne s new
Seanheu (Syttom s new stahner
leanner 07:0541
-snentline t);
string ; Lting s) l))
Atay
char cl) S. to Char char c cI - S1. to charArray
new. fnt [56J:
schol.

c1J'o';

jSength s jt+)§
Hor (int j 0

+ 48);

fist hon repeat :


length ; jt){
tor tint je0 3 je Sp- 0+4)
iz256 S
tor tint iz 0 ;

Sumation Acat value

pubtie statie veid main (ting C3 args) 995

Sccsher s hew eanner Csystem. in); .


tubie eleus olgits ar:) f
(34r ng [] REI23

lie ttatie void main


pub
&um t st. char At li):
lcanney
hew
Seanner
(systm. false

String tr S. hey t Line ;


()}
= 2tr. o Chau Array
chau c

l'false ' ;
out pint
25-01- 5 3yatem
n;

Sptehartui prìntinq:
8 - 0 . p ' n e ' ) ;

(Stnng C7 args){
ublie tatie void majn RITOI23.
(System. In) 3 ohly tor
Scarner & = new Seanner e Her
Sinale
eha cl3 =4 to char Array l ); Pustte J arzs)
it+) $ (Ning
tor (int izo ; icet. length ) Pubic statie
void man
£canner [Link]) ;
Scanner

stzing

chau writen

when o þetati on
(cha) the c would
Þewforred

ba cÓn veste d
tovesi ons ika wing As di
So We kave to type
-47 print the
aA -32) caut nd
A
char to Inte
changing the tirtt etor o! a sting to up pe case t

Pubie else A.-P(Ii)+ownt ))


lass tstutter change {
Pubtüe statte void maln (3tning C] ang) Sinu we added
Bcanne e DRw lcanne tytem in ), pito spau betn
Hert like listen
both word muu
b hene all le silent }
the
94Y 4 tr
Was
Pubtie elas Anagram (Hning C7 ags)
t+}} stahe void maln
to Cint izl ; iz elenq t* hì hello publie Caystemh);
Bcanner
Bcanner & new
neutine C);
Hi Hetlo. Btring ttri = -
Chartray C)S
S 0-P (ehas) ( eth7- 32)); ehar cy = trt. to
huttine ).
ontinue ) &Brnng sBra =
Char trray U;
Cheu c = str9. to
ncemeht the

i+){
dor (int iz0 ; ie e- length ;
C++)

trea lGLiJ) ++; dcrement the


wunt

-)
Compress sting using ehauacter coLnt (

pubtie clacs compchar count f


PUsee statit void main (string [7 st)
Stanner s hew sahher ( Syutem. in). ye then

char ci e Btr. tocharAray t): stolength l), twunt=1)


fangiam Al the alphabet Muat be Present the
emalst and agest
w67d in a Qting
$
(8ting 3 augs)
angthotwod

QLblie class void main


Dubtie static %= hw 2eanne [Link]) , lage
Sring s Aete RCanner
char elJ & to CharAray C
boolean alpha.] new booean abe de
hrmay
tt. to Oh aa anm a
not a Panqram thar e tJ =
Int n= clength , i , indek = Q43
Large girt.
-for (int i s0 ; len i+)
wwwtsYon y &mall o
lago worde are
index = eIi7-'as Pangram qiven then
Uongiter tho st
Smalleat or farg

index cCiJ- ' eunent

alpha indx J tru ;


Lorge index ;
i++)
is0 ; ie
tox tint

it (alpha Ci] false ) tength )) f


wordi C1J-
3- 6. ( Not a pangram ; Large .length, t) >
0 ( = wordt CiJ;

(arge

(rngram '); + lauge)>


Carge
Smal! ,
+
Print matrtX

Pubie dass mati x


Pubee 2tatie. void main (ning [I aIg s)}
SCanner & new gCanhex (system. in);
Ynt JCI a new i n t , J [ ]

for tint is0; jer; it+)f


!
fo tint j=0 ; ec jt+) $ min
elenment in
hatir

it+)f VALUE
-for (int ir0 } ier ; |2 Int min
lnteger. MAK_

tor (int jso; jeej j4+)§ 3 4

for (inejz 0 ) jze jtt){


a i 3 j= e x t fnt;

9
min aTijJ;

max element in matK:

Public clas Mar matrix § for tine j=0: je i i+){


Pubie statie void ma in S.0p ariJtjJ +
");
lAyetem. in)j
Scanner s new Seannen le]
[]
new int
Iht [) C) a
cr; itH)$
tor Cint izb ; i t4)
0: j4c
for tint Jr

a To] l'o) ;

tor (intj 0; je C;jt*)


ach ow ji*)!
jeei
jb)
ht rr9 a ew int : tor (int

Mava
Ei7 Cj 7;
1

fou (int j-o jeci j++)f yes


i4 (max aCiJCì){
max a [iJ[j7;

Min o each row [Link]'ye');

I Simlau tode 3
M) M2

Pubäe elass sumotmati (in iz0; i 24


Pubic gtatic vold main Cshing l7 aug)
Scanney sr new Sianner lsystem.
in):
Int aJCI
}it*) 34
tor (int is6 ;
iI
(int t z0; izr; i4+)}
for
q 12

Sum + aliej;
wl2

diplay (a):
S.0p (3um):

(int a g3D
Pi vate stati c void daplay to emre the

eNeate
MUs t
je ;i ) CNeate object for we
for (int ir0; another r0grm,
jt*){ call trom .
the base code
jc) vethod
dor tint jz 0> E ue
nequired claK OA
pbject in the
ew Bumotmatn ).
Sm. diplaytasi
Ony to tool &m. diplay tb)s
Sm. display (swn)s
4ue hot to bhiu
ftls
Sum of matnx method
write thiu
sumofmatir f
nPrev code
PUbic las a17C)
matn (sting lI
ags)f
Pubtle vojd dùp lay (int
Pubtie static void
Scannew
SCanneu s new
writo thi:
betore sCanney
new ht r][c];
mutipcati on ot matnx idntial
or hot.

class
Zdentical main (shing 27 arys)i
get the mattiX as nut and then puslic tatie
void
C8yctem. in);
Pule & ew Reunnr
for (int is0 ; ie J++ ) tanner
- et Dnt l);
etDntt),
nt r &.
for Cint )=0) jee j jt){
C:JLc]; 4 4
tor (int k o k e c ) k++)} new int
Ank
BtIC] 3 4
26
70 hot identi cal

(intj=0 jee ) jtt)}


for Int()i
aciTLjI : S-uet
Sm diuplay (mul):
j jer;i++)f
o Cint iz 0 jt)
Jor tint
J=0 ; j2e;
blìJL)J =
8rext ntU

O2
6,0
is0; ier;i+)$
2, 0 4or tint jt+){.
jee
Hor (int /r0
matiX
and dut e ,

fat J = c-I; d trn


(

S - 0 - p t & e n t i e a / ) :

rofate ta): x).


void to tate ( int C3tI
matix
publie &tatie
the
diH Suml- Sum 90 Ro tate

matn / 4 3
qet a 14

cigjJ);
se
(-op (diE#);
S- o-P (a
Paten Right angle triange fer

Pubtie las main


ags)?
Pus tic atatie void mein tsaìng CJ

r lin i+4)

jo j--)$
for
(int / D-i-1;
klt angl tiangu
Publie class ain
Pubie gtatie void main 1

Io0) (o) to,2)


Jor (int is 0; jen it)f jiamond shape.:
tor ( i n t 0 ;j)$
ien ++)}
tor tint
S-o.p ( ");
nove

S-o.p ln l) ;

Pyramid i
je i'yi) S.
(n-)-);js0s
J--){ dor lint jr0 ;
tor. (int j 8.0-p ( 4):

ln-i-D:7 0 --)f
for lint je
Jor (int ): 0y i nitt)F
he= P
n > p - r

j--)
for lint j= n-i; j>0j

$-0pln C);

elses
Tes Ch 4 - 0 ( y e s ) s

ning Qnd she plantt treet fn hey


hmo re
Sara u intrested so much in qaude 0rder ot roue
rectangular fahion with the
qauden. the plants tres in a order and
olumn wite
numbered the tres fn
and coumne. She and last o bim n.
in 8t row , |8t co bumn
Hexa deumal

Plantod mango tte onty wite a program ind Bletohur


s
Print ttex

trees, K a iango
&o i ven the namber of +ree
Publie olels
lnt n
whether he given tee is a mango iB lnez 0)

9 tntogers
Print ex (h/6)
Publle elass
maìn (ing L7 aug)f
Pub tic &tatie Void
new &cD neu
( System-in):
Btanne4 t, )yPj (r-o));
n= s- RxtDn 8-0-P (Cohe) ('4'
(sting
Seam Se z Nw Stane (Sytem. n .
Aeeimalt > Vaue ba i
hase = Bj

Ntun deùma!;

So-pln c);
SC- eloa ) Bcanneu e = wSanne (system- m)s
tng
Hexa decçnel to decima

Pubie cas tteetodeu §


Pefies herto dinal (iag hex)
tnt deciMal D;
0nt baue l ;

char ch = hex -charA+ Ci);


înt valu;

value = ch o'

vatue ch- ^A+|8;

Vaue chtat 9

+ch)
8-6- phlInvalid hxa decëmel :

You might also like