Computer Science Project 12th

  • Upload
    harshit

  • View
    223

  • Download
    0

Embed Size (px)

Citation preview

  • 8/9/2019 Computer Science Project 12th

    1/75

    COMPUTERSCIENCE

    PROJECT

    1

  • 8/9/2019 Computer Science Project 12th

    2/75

    MADE BY:-

    HARSHIT SINGH DEWAL

    XII-A

    ContentsNO. PROGRAM PAGE NO.1 Magic Square 4

    2 Spiral Matrix 7

    3 GCD (Using Recursion) 10

    4 Fibonacci Series (Using Recursion) 12

    5 Factorial (Using Recursion) 14

    6 Calendar of Any Month 16

    7 AP Series 198 Number in Words 22

    9 Pascals Triangle 24

    10 Linear Search 26

    11 Binary Search 29

    12 Selection Sort 32

    13 Bubble Sort 35

    14 Date Program 38

    15 Decimal to Binary Number 41

    16 Replacing Vowels with * 43

    17 Word Count 45

    18 Number of Vowels and Consonants 47

    19 String in Alphabetical Order 49

    2

  • 8/9/2019 Computer Science Project 12th

    3/75

    20 Decoding of String 52

    21 Word Search in String 55

    22 Frequency of Each String Character 57

    23Palindrome Check

    6024 Star Pattern Using Input String 62

    25 Sum of All Matrix Elements 64

    26 Sum of Matrix Column Elements 67

    27 Sum of Matrix Diagonal Elements 70

    28 Sales commission 73

    29 Decimal to Roman Numerical 75

    30 Celsius to Fahrenheit (Using

    Inheritance)

    77

    ACKNOWLEDGEMENTS

    First of all, Id like to thank my parents for

    helping me out with the project.Secondly, Id like to thank our Computer

    teachers Mr. Akhilesh ajpai for helping us

    with the programs.

    !astly, Im really grateful to "a#ish $aider

    %i&'i whose help was imperati'e for myself

    making this project.

    PROGRAM 1:3

  • 8/9/2019 Computer Science Project 12th

    4/75

    Magic Square

    ALGORITHM

    STEP 1 - START

    STEP 2 - arr[][]=new int[n][n],c=n/2-1,r=1,num

    STEP 3 - IF num=1;numn-1 GOTO STEP 8

    STEP 8 - c=0

    STEP 9 - IF arr[r][c]!=0 GOTO STEP 10STEP 10 - r=r+2 & c

    STEP 11 - num++ & IF num

  • 8/9/2019 Computer Science Project 12th

    5/75

    STEP 18 - IFr=0 GOTO STEP 19

    STEP 19 - IF c=0 GOT STEP 20

    STEP 20 - PRINT arr[r][c]+" " & ()

    STEP 21 - c++ & IF c

  • 8/9/2019 Computer Science Project 12th

    6/75

    'or0r7?-r;-r

  • 8/9/2019 Computer Science Project 12th

    7/75

    PROGRAM 2:

    S*iral Matri

    Algorit%&

    STEP 1 STARTSTEP 2 INPT aSTEP 3 IJ *@70itMat%.*o$0l)2 GOTO STEP 4STEP 4 IJ co@7? GOTO STEP STEP re71

  • 8/9/2019 Computer Science Project 12th

    8/75

    STEP F IJ ri71-ri;7K1re-ri

  • 8/9/2019 Computer Science Project 12th

    9/75

    *

  • 8/9/2019 Computer Science Project 12th

    10/75

    PROGRAM 3:GD 0#ig Recur#io

    Algorit%&STEP 1 START

    STEP 2 - INPUT p,q

    STEP 3 - IF(q=0) THEN return p OTHERWISE return calc(q,p%q)

    STEP 4 END

    Solutioi&*ort +a,a.io."-

    cla## GD*u/lic #tatic ,oi( &ai0Strig arg# t%ro$# IOEce*tio !!&ai'uctio5u6ere(Rea(er /r 7 e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09eter t%e u&/er# 79-it * 7 Iteger.*ar#eIt0/r.rea(Lie0-it q 7 Iteger.*ar#eIt0/r.rea(Lie0-GD o/+ 7 e$ GD0-it g 7 o/+.calc0*)q-S8#te&.out.*ritl09GD 79

  • 8/9/2019 Computer Science Project 12th

    11/75

    *u/lic it calc0it *)it q !!recur#i,e 'uctio calculatig GDi'0q77?retur *-el#e retur calc0q)*Qq-

    Caria/le De#cri*tioNO. NAME TYPE METHOD DESCRIPTION1 /r 5u6ere(Rea(

    er&ai0 5u6ere(Rea(er o/+ect

    2 * it &ai0 )calc0

    i*ut u&/er

    3 q it &ai0 )calc0

    i*ut u&/er

    4 o/+ GD &ai0 GD o/+ect5 g it &ai0 ,aria/le #torig t%eGD

    Output

  • 8/9/2019 Computer Science Project 12th

    12/75

    PROGRAM 4:Ji/oacci Serie# 0#ig Recur#io

    Algorit%&STEP 1 - START

    STEP 2 - INPUT n

    STEP 3 - IF(n

  • 8/9/2019 Computer Science Project 12th

    13/75

    'or0it i71-i;7-i

  • 8/9/2019 Computer Science Project 12th

    14/75

    PROGRAM :Jactorial 0#ig Recur#io

    Algorit%&STEP 1 START

    STEP 2 - INPUT n

    STEP 3 - IF(n

  • 8/9/2019 Computer Science Project 12th

    15/75

    it 7 Iteger.*ar#eIt0/r.rea(Lie0- !!acce*tig o.Jactorial o/+ 7 e$ Jactorial0-log ' 7 o/+.'act0-S8#te&.out.*ritl09Jactorial 79

  • 8/9/2019 Computer Science Project 12th

    16/75

    PROGRAM F:ale(ar o' A8 Mot% O' a8 ear

    Algorit%&STEP 1 STARTSTEP 2 INPT it &ot%)it 8earSTEP 3 it i)cout7?)/)c)(71 B Strig $79SMTTJS9STEP 4 IJ 08earQ1??77? BB 8earQ4??77? UU 08earQ1??@7? BB 8earQ477?STEP (a8#172STEP F PRINT 97777777777777777T%e ale(ar o'9

  • 8/9/2019 Computer Science Project 12th

    17/75

    STEP 1F IJ cout>? GOTO STEP 1)1STEP 1 PRINT V V? BB IJ (;7(a8#&ot%1 GOTO STEP 21)22STEP 21 PRINT (

  • 8/9/2019 Computer Science Project 12th

    18/75

    /-/7-S8#te&.out.*ritl09 9-

    Caria/le De#cri*tio

    NO. NAME TYPE METHOD DESCRIPTION1 /r 5u6ere(Rea(er (ee0 5u6ere(Rea(er O/+ect2 i it (ee0 loo* ,aria/le3 cout it (ee0 couter4 / it (ee0 $eeK couter5 ( it (ee0 (a8 couter6 &ot% it (ee0 i*ut &ot%% 8ear it (ee0 i*ut 8ear

    & $ Strig (ee0 $eeK (a8#' (a8# Strig (ee0 arra8 #torig (a8#1( &ot%1 Strig (ee0 arra8 #torig &ot%#

    Output

  • 8/9/2019 Computer Science Project 12th

    19/75

    PROGRAM :A.P. Serie# a( it# Su&

    Algorit%&

    STEP 1 - START

    STEP 2 - a = d = 0

    STEP 3 - IMPORT a, d

    STEP 4 - this.a = a & this.d = d

    STEP 5 - IMPORT n

    STEP 6 - RETURN (a+(n-1)*d)

    STEP 7 - IMPORT n

    STEP 8 - RETURN (n*(a+nTHTerm(n))/2)

    STEP 9 - IMPORT n

    STEP 10 - PRINT \n\tSeries\n\t"

    STEP 11 - IF i=1;i

  • 8/9/2019 Computer Science Project 12th

    20/75

    S8#te&.out.*rit0THTer&0i

  • 8/9/2019 Computer Science Project 12th

    21/75

    PROGRAM :Nu&/er I or(#

    Algorit%&STEP 1 - STARTSTEP 2 - INPUT amt

    STEP 3 - z=amt%10 , g=amt/10

    STEP 4 - IF g!=1 THEN GOTO STEP 5 OTHERWISE GOTO STEP 6 STEP 5 - PRINT x2[g-

    "+x1[z]

    STEP 6 - PRINT x[amt-9]

    STEP 7 END

    Solutioi&*ort +a,a.io."-cla## Nu&2or(#*u/lic #tatic ,oi( &ai0Strig arg#t%ro$# IOEce*tio !!&ai'uctio5u6ere(Rea(er /r7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09Eter a8 Nu&/er0le## t%a 9-it a&t7Iteger.*ar#eIt0/r.rea(Lie0- !!acce*tig u

  • 8/9/2019 Computer Science Project 12th

    22/75

    it Z)g-Strig7WX)9Te9)9Ele,e9)9T$el,e9)9T%irtee9)9Jourtee9)9Ji'tee9)9Sitee9)9Se,etee9)9Eig%tee9etee9-

    Strig 1799)9Oe9)9T$o9)9T%ree9)9Jour9)9Ji,e9)9Si9)9Se,e9)9Eig%t9)9Nie9-Strig 2799)9T$et89)9T%irt89)9Jourt89)9Ji't89)9Sit89)9Se,et89)9Eig%t89)9NiZ7a&tQ1?- !!=(ig t%e u&/er ig7a&t!1?-i'0g@71S8#te&.out.*ritl02g1

  • 8/9/2019 Computer Science Project 12th

    23/75

    PROGRAM :Pa#cal[# Triagle

    Algorit%&STEP 1 STARTSTEP 2 *a#? 7 1STEP 3 IJ i7? THEN GOTO STEP 4

    STEP 4 IJ +7? THEN GOTO STEP STEP PRINT *a#+

  • 8/9/2019 Computer Science Project 12th

    24/75

    Solutioi&*ort +a,a.io."-cla## Pa#cal*u/lic ,oi( *a#cal$0t%ro$# IOEce*tio !!*a#cal$0 'uctio5u6ere(Rea(er /r7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-

    S8#te&.out.*ritl0WEter a o.X-it 7Iteger.*ar#eIt0/r.rea(Lie0- !!acce*tig ,alueit *a# 7 e$ it

  • 8/9/2019 Computer Science Project 12th

    25/75

    PROGRAM 1?:Liear Searc%

    Algorit%&STEP 1 - START

    STEP 2 - INPUT a[]

    STEP 3 - FROM i=0 to i

  • 8/9/2019 Computer Science Project 12th

    26/75

  • 8/9/2019 Computer Science Project 12th

    27/75

    *u/lic ,oi( #earc%0it , !!liear #earc% 'uctioit \ag71-'or0it i7?- i; - i

  • 8/9/2019 Computer Science Project 12th

    28/75

    PROGRAM 11:5iar8 Searc%

    Algorit%&STEP 1 - START

    STEP 2 - INPUT a[]

    STEP 3 - FROM i=0 to i

  • 8/9/2019 Computer Science Project 12th

    29/75

    Solutioi&*ort +a,a.io."-cla## 5iar8Searc%it )i-it a 7 e$ it1??-#tatic 5u6ere(Rea(er /r 7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-

    *u/lic 5iar8Searc%0it !!(e'ault co#tructor7-*u/lic ,oi( i*ut0 t%ro$# IOEce*tioS8#te&.out.*ritl09eter ele&et#9-'or0i7?-i;-i

  • 8/9/2019 Computer Science Project 12th

    30/75

    i'0a& 77 ,\ag 7 &-el#e i'0a& ; ,l 7 &

  • 8/9/2019 Computer Science Project 12th

    31/75

    PROGRAM 12:Selectio Sort

    Algorit%&STEP 1 - START

    STEP 2 - INPUT a[]

    STEP 3 - FROM i=0 to i

  • 8/9/2019 Computer Science Project 12th

    32/75

    Solutioi&*ort +a,a.io."-cla## SelectioSortit )i-it a 7 e$ it1??-*u/lic SelectioSort0it !!*ara&eteriZe( co#tructor7-

    *u/lic ,oi( i*ut0 t%ro$# IOEce*tio5u6ere(Rea(er /r 7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09eter ele&et#9-'or0i7?-i;-i

  • 8/9/2019 Computer Science Project 12th

    33/75

    i'0&i@7ite&* 7 ai-ai 7a&i-a&i 7 te&*-*u/lic #tatic ,oi( &ai0Strig arg# t%ro$# IOEce*tioSelectioSort 7 e$ SelectioSort0-

    .i*ut0-S8#te&.out.*rit095e'ore #ortig 9-.(i#*la80-S8#te&.out.*rit09A'ter #ortig 9-.#ort0-.(i#*la80-

    Caria/le De#cri*tio

    NO. NAME TYPE METHOD DESCRIPTION

    1 /r 5u6ere(Rea(er i*ut 5u6ere(Rea(er O/+ect2 it arra8 legt%3 i it loo* ,aria/le4 a it i*ut arra85 it SelectioSo

    rt0*ara&eter i co#tructor

    6 + it Sort0 #ort i(e% te&* it Sort0 te&*orar8 #torage& &i it Sort0 &ii&u& ,alue' Selectio #ort &ai0 SelectioSort o/+ect

    Output

  • 8/9/2019 Computer Science Project 12th

    34/75

    PROGRAM 13:555LE Sort

    Algorit%&STEP 1 - START

    STEP 2 - INPUT a[]

    STEP 3 - FROM i=0 to i

  • 8/9/2019 Computer Science Project 12th

    35/75

    Solutioi&*ort +a,a.io."-cla## 5u//leSortit )i-it a 7 e$ it1??- *u/lic 5u//leSort0it

    7- !!*ara&eteriZe( co#tructor*u/lic ,oi( i*ut0 t%ro$# IOEce*tio5u6ere(Rea(er /r 7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09eter ele&et#9-'or0i7?-i;-i

  • 8/9/2019 Computer Science Project 12th

    36/75

    'or0+7? - +;1i - +

  • 8/9/2019 Computer Science Project 12th

    37/75

  • 8/9/2019 Computer Science Project 12th

    38/75

    STEP 12 - PRINT d + "th" + m[s] + " , "+yr

    STEP 13 END

    Solutioi&*ort +a,a.io."-cla## Da82Date#tatic 5u6ere(Rea(er /r 7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&*u/lic ,oi( calc0it ) it 8r !!'uctio to calculate (ait a 7 31)2)31)3?)31)3?)31)31)3?)31)3?)31 -Strig & 7 9Ya9) 9Je/9)9Mar9)9A*r9)9Ma89)9Yu9)9Yul9)9Aug9)9Se*9)9Oct9)9No,9)9Dec9 -i' 0 8r Q 4 77 ?a1 72-it t7?)#7?-$%ile0 t ; !!loo* calculatig (atet 7t < a#

  • 8/9/2019 Computer Science Project 12th

    39/75

    S8#te&.out.*ritl0 ( < 9(9 < < 9 ) 9

  • 8/9/2019 Computer Science Project 12th

    40/75

    PROGRAM 1:Deci&al to 5iar8

    Algorit%&STEP 1 - START

    STEP 2 - n = 30

    STEP 3 - INPUT int no

    STEP 4 - c =0 , temp = no

    STEP 5 - IF (temp!=0) REPEAT STEP 6STEP 6 - a[c++] = temp%2, temp = temp / 2

    STEP 7 - FROM i=c-1 to i>0 REPEAT STEP 8

    STEP 8 - PRINT a[i]

    STEP 9 END

    Solutioi&*ort +a,a.io."-cla## Dec25i

  • 8/9/2019 Computer Science Project 12th

    41/75

    it )i-it a 7 e$ it1??-#tatic 5u6ere(Rea(er /r 7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&*u/lic Dec25i0it !!*ara&eteriZe( cotructor7-*u/lic ,oi( (ecto/i0it o !!'uctio co,ertig (eci&alto /iar8 u&

    it c 7 ?-it te&* 7 o- $%ile0te&* @7 ? ac

  • 8/9/2019 Computer Science Project 12th

    42/75

    PROGRAM 1F:Re*lacig Co$el# $it% "

    Algorit%&STEP 1 - STARTSTEP 2 - a = "Computer Applications"

    STEP 3 - x= 0

    STEP 4 - FROM z =0 to z

  • 8/9/2019 Computer Science Project 12th

    43/75

    S8#te&.out.*ritl09Origial Strig 9

  • 8/9/2019 Computer Science Project 12th

    44/75

    PROGRAM 1:or( out

    Algorit%&STEP 1 - START

    STEP 2 - a = "Computer Applications"

    STEP 3 - z = a.length()

    STEP 4 - x= 0

    STEP 5 - FROM y =0 to y

  • 8/9/2019 Computer Science Project 12th

    45/75

    5u6ere(Rea(er /r7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09Eter Setece9-Strig a7/r.rea(Lie0- !!acce*tig #trigS8#te&.out.*ritl09T%e #trig i# 9

  • 8/9/2019 Computer Science Project 12th

    46/75

    PROGRAM 1:Nu&/er o' Co$el# a( o#oat#

    Algorit%&STEP 1 - START

    STEP 2 - a = "Computer Applications"

    STEP 3 - z = a.length()

    STEP 4 - x= 0 , b= 0

    STEP 5 - FROM y =0 to y

  • 8/9/2019 Computer Science Project 12th

    47/75

    Solutioi&*ort +a,a.io."-cla## Co$el#*u/lic #tatic ,oi( &ai0Strig arg#t%ro$# IOEce*tio !!&ai'uctio

    5u6ere(Rea(er /r7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09Eter a #trig9-Strig a7 /r.rea(Lie0- !!Acce*tig #trigit Z7a.legt%0)8)7?)/7?-'or087?-8;Z-8

  • 8/9/2019 Computer Science Project 12th

    48/75

    PROGRAM 1:Strig i Al*%a/etical or(er

    Algorit%&STEP 1 - START

    STEP 2 - str = "" , l = 0

    STEP 3 - INPUT string str

    STEP 4 - l =str.length()

    STEP 5 - FROM i=0 to i

  • 8/9/2019 Computer Science Project 12th

    49/75

    STEP 12 END

    Solutioi&*ort +a,a.io."-cla## Al*%a

    Strig #tr-it l-c%ar c 7 e$ c%ar1??-*u/lic Al*%a0 !!Al*%a0 co#tructor#tr 7 99-l 7?-*u/lic ,oi( rea($or(0 t%ro$# IOEce*tio !!'uctio to rea( i*ut #trigS8#te&.out.*ritl09eter $or( 9-

    5u6ere(Rea(er /r 7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-#tr 7 /r.rea(Lie0-l 7 #tr.legt%0-*u/lic ,oi( arrage0 !!'uctio to arrage #trig i a#ce(or(erit i)+-c%ar te&*-'or0i7?-i;l-i

  • 8/9/2019 Computer Science Project 12th

    50/75

    'or0i7?-i;l1-i

  • 8/9/2019 Computer Science Project 12th

    51/75

    PROGRAM 2?:Deco(ig o' Strig

    Algorit%&STEP 1 - START

    STEP 2 - INPUT name, n

    STEP 3 - l=name.length()

    STEP 4 - PRINT original string is "+name

    STEP 5 - IF i=0 THEN GOTO STEP 6

    STEP 6 - char c1=name.charAt(i)

    STEP 7 - c=(int)c1

    STEP 8 - IF n>0 THEN GOTO STEP 9 THERWISE GOTO STEP 12

    STEP 9 - IF (c+n)

  • 8/9/2019 Computer Science Project 12th

    52/75

    STEP 15 - DISPLAY (char) (c-n1)

    STEP 16 - IF c>65 THEN GOTO STEP 17 OTHERWISE GOTO STEP 18

    STEP 17 - c=c-65,

    STEP 18 - c=n1 & PRINT (char)(90-(c-1))

    STEP 19 - ELSE IF n==0

    STEP 20 - DISPLAY "no change "+name

    STEP 21 - END

    Solutioi&*ort +a,a.io."-cla## Deco(e

    *u/lic ,oi( co&*ute0t%ro$# IOEce*tio !!co&*ute0 'uctio5u6ere(Rea(er /r7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl0WEter a&e:X-Strig a&e7/r.rea(Lie0-S8#te&.out.*ritl0WEter u&/er:X-it 7Iteger.*ar#eIt0/r.rea(Lie0-it +)i)l)c7?)8)1-l7a&e.legt%0-S8#te&.out.*ritl09origial #trig i# 9

  • 8/9/2019 Computer Science Project 12th

    53/75

    c7c

  • 8/9/2019 Computer Science Project 12th

    54/75

    PROGRAM 21:or( Searc% I Strig

    Algorit%&STEP 1 - START

    STEP 2 - INPUT string s

    STEP 3 - StringTokenizer st = s

    STEP 4 - l =str.length()

    STEP 5 - INPUT look

    STEP 6 - flag = -1

    STEP 7 - IF (st.hasMoreElements()) REPEAT STEP 8

    STEP 8 - IF (look.equals(st.nextElement())) THEN flag =1STEP 9 - IF flag = - 1 GOTO STEP 10 OTHERWISE STEP 11

    STEP 10 - PRINT "word not found"

    STEP 11 - PRINT "word found"

    STEP 12 END

    Solutioi&*ort +a,a.util.StrigToKeiZer-i&*ort +a,a.io."-

  • 8/9/2019 Computer Science Project 12th

    55/75

    *u/lic cla## or(Searc%*u/lic #tatic ,oi( &ai0Strig arg# t%ro$# IOEce*tio !!&ai 'uctio5u6ere(Rea(er /r 7 e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09eter t%e #trig79-Strig # 7 /r.rea(Lie0- !!acce*tig #trigStrigToKeiZer #t 7 e$ StrigToKeiZer0#)9 9- !!StrigToKeiZeiitialiZatioS8#te&.out.*ritl09eter t%e $or( to /e #earc%e( 79-

    Strig looK 7 /r.rea(Lie0-it \ag 7 1-$%ile0#t.%a#MoreEle&et#0 !!#earc%ig 'or $i'0looK.equal#0#t.etEle&et0\ag 71-i'0\ag 771S8#te&.out.*ritl09t%e $or( ot 'ou(9- el#e S8#te&.out.*ritl09t%e $or( 'ou(9-

    Caria/le De#cri*tio

    NO. NAME TYPE METHOD DESCRIPTION1 /r 5u6ere(Rea(er &ai0 5u6ere(Rea(er O/+ect2 # Strig &ai0 i*ut Strig

    3 #t StrigToKeiZer &ai0 StrigToKeiZer o/+ect4 looK Strig &ai0 $or( to /e #earc%e(5 it it &ai0 \ag

    Output

  • 8/9/2019 Computer Science Project 12th

    56/75

    PROGRAM 22:Jrequec8 o' Eac% Strig %aracter

    Algorit%&STEP 1 - START

    STEP 2 - INPUT str

    STEP 3 - l=str.length()

    STEP 4 - PRINT str

    STEP 5 - IF i=0 THEN GOTO STEP 4 OTHERWISE GOTO STEP 6

    STEP 6 - char a=str.charAt(i)

    STEP 7 - IF ii=0 THEN GOTO STEP 4 OTHERWISE GOTO STEP 8

    STEP 8 - char b = str.charAt(ii)

    STEP 9 - IF a==b GOTO STEP 10

    STEP 10 - freq=freq+1

    STEP 11 - ii++ & IF ii

  • 8/9/2019 Computer Science Project 12th

    57/75

    STEP 14 END

    Solutioi&*ort +a,a.io."-cla## Jrequec8

    *ri,ate it i)a1)l)*)+)'req-*u/lic Jrequec80 !!(e'ault co#tructor*7?-'req7?- !! iitiali#e i#tace ,aria/le#*u/lic ,oi( cout0Strig #tr !!coutig c%aracter 'requecit ii-l7#tr.legt%0-S8#te&.out.*rit0#tr-

    'or0i7?-i;l-i

  • 8/9/2019 Computer Science Project 12th

    58/75

    NO. NAME TYPE METHOD DESCRIPTION1 /r 5u6ere(Rea(er &ai0 5u6ere(Rea(er O/+ect2 i it loo* ,aria/le3 a1 it i#tace ,arira/le4 l it legt% o' #trig5 * it i#tace ,aria/le6 'req it 'requec8 o' c%aracter#

    % ii it cout0 loo* ,aria/le& a c%ar cout0 c%aracter at i(e i' / c%ar cout0 c%aracter at i(e ii1( #tr Strig &ai0 i*ut Strig11 Jrequec8 &ai0 'requec8 o/+ect

    Output

    PROGRAM 23:Pali(ro&e %ecK

  • 8/9/2019 Computer Science Project 12th

    59/75

    Algorit%&STEP 1 - START

    STEP 2 - INPUT string s

    STEP 3 - StringBuffer sb = s

    STEP 4 - sb.reverse

    STEP 5 - String rev = sbSTEP 6 - IF rev = s GOTO STEP 7 OTHERWISE GOTO STEP 8

    STEP 7 - PRINT " Palindrome"

    STEP 8 - PRINT " Not Palindrome"

    STEP 9 END

    Solutioi&*ort +a,a.io."-

    cla## Pali(ro&e*u/lic #tatic ,oi( &ai0Strig arg# t%ro$# IOEce*tio !!&ai'uctio5u6ere(Rea(er /r 7 e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09eter t%e #trig79-Strig # 7 /r.rea(Lie0- !!acce*tig t%e #trigStrig5u6er #/ 7 e$ Strig5u6er0#-#/.re,er#e0- !!re,er#ig t%e #trigStrig re, 7 e$ Strig0#/-

    i'0#.equal#Igorea#e0re, !!c%ecKig 'or *ali(S8#te&.out.*ritl09Pali(ro&e 9 - !!(i#*la8ig t%e re#uel#eS8#te&.out.*ritl09Not Pali(ro&e 9 -

    Caria/le De#cri*tio

    NO. NAME TYPE METHOD DESCRIPTION1 /r 5u6ere(Rea(er &ai0 5u6ere(Rea(er O/+ect2 # Strig &ai0 i*ut #trig

  • 8/9/2019 Computer Science Project 12th

    60/75

    3 #/ Strig5u6er &ai0 Strig5u6er o/+ect o' #4 re, Strig &ai0 re,er#e #trig

    Output

    PROGRAM 24:Star Patter #ig I*ut Strig

    Solutioi&*ort +a,a.io."-

  • 8/9/2019 Computer Science Project 12th

    61/75

    cla## Patter*u/lic #tatic ,oi( &ai 0Strig arg# t%ro$# IOEce*tioit i)#*)+)K)l-5u6ere(Rea(er /r 7 e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09eter t%e #trig 79- !!acce*tig #trigStrig # 7 /r.rea(Lie0-l7#.legt%0-

    !"*ritig t%e *atter"!'or0i7?-i;l-i

  • 8/9/2019 Computer Science Project 12th

    62/75

    Output

    PROGRAM 2:Star Patter #ig I*ut Strig

    Algorit%&STEP 1 - START

    STEP 2 - INPUT a[]

    STEP 3 - FROM x =0 to x

  • 8/9/2019 Computer Science Project 12th

    63/75

    STEP 6 - FROM x =0 to x

  • 8/9/2019 Computer Science Project 12th

    64/75

    Caria/le De#cri*tio

    NO. NAME TYPE METHOD DESCRIPTION1 aa 5u6ere(Rea(er &ai0 5u6ere(Rea(er O/+ect2 a it &ai0 i*ut arra83 it &ai0 loo* ,aria/le

    4 8 it &ai0 loo* ,aria/le5 Z it &ai0 i*ut ele&et6 Su& &ai0 &ai0 Su& o' all ele&et#

    Output

    PROGRAM 2F:Su& O' Matri olu& Ele&et#

  • 8/9/2019 Computer Science Project 12th

    65/75

    Algorit%&STEP 1 - START

    STEP 2 - INPUT a[]

    STEP 3 - FROM x =0 to x

  • 8/9/2019 Computer Science Project 12th

    66/75

    S8#te&.out.*rit0a8

  • 8/9/2019 Computer Science Project 12th

    67/75

    PROGRAM 2:Su& O' Matri Diagoal Ele&et#

    Algorit%&STEP 1- STARTSTEP 2- INPUT a[]

    STEP 3- FROM x =0 to x

  • 8/9/2019 Computer Science Project 12th

    68/75

    i&*ort +a,a.io."-cla## DiagoalSu&*u/lic #tatic ,oi( &ai0Strig arg#t%ro$# IOEce*tio

    !!&ai 'uctioit a7e$ it44-5u6ere(Rea(er aa7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-it )8)Z)Su&7?-

    S8#te&.out.*ritl09Eter t%e arra89-'or07?-;4-

  • 8/9/2019 Computer Science Project 12th

    69/75

    3 it &ai0 loo* ,aria/le4 8 it &ai0 loo* ,aria/le5 Su& it &ai0 Su& o' Diagoal#6 Z it &ai0 i*ut ele&et#

    Output

    PROGRAM 2:Sale# o&&i##ioSales Commission

    ()*+++++ - of sales

    /++++011111 .- of sales

    2++++031111 + of sales4++++0-1111 *- of sales

    54++++ *.- of sales

    Algorit%&STEP 1 - START

    STEP 2 - INPUT sales

  • 8/9/2019 Computer Science Project 12th

    70/75

    STEP 3 -IF (sales>=100000) THEN comm=0.25 *sales OTHERWISE GOTO STEP 4

    STEP 4 - IF (sales>=80000) THEN comm=0.225*sales OTHERWISE GOTO STEP 5

    STEP 5 - IF (sales>=60000) THEN comm=0.2 *sales OTHERWISE GOTO STEP 6

    STEP 6 - IF (sales>=40000) THEN comm=0.15 *sales OTHERWISE GOTO STEP 7

    STEP 7 - comm=0.125*sales

    STEP 8 - PRINT "Commission of the employee="+comm

    STEP 9 END

    Solutioi&*ort +a,a.io."-cla## Sale#o&i##io*u/lic #tatic ,oi( &ai0Strig arg#t%ro$# IOEce*tio !!&ai'uctio(ou/le #ale#)co&&-5u6ere(Rea(er aa7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl0WEter #ale#X-#ale#7Dou/le.*ar#eDou/le0aa.rea(Lie0- !!rea(ig #ale# 'ro& Ke8/oar(!"calculatig co&&i##io"!i'0#ale#>71?????co&&7?.2"#ale#-el#e i'0#ale#>7????co&&7?.22"#ale#-el#e i'0#ale#>7F????co&&7?.2"#ale#-el#e i'0#ale#>74????

    co&&7?.1"#ale#-el#e co&&7?.12"#ale#-S8#te&.out.*ritl09o&&i##io o' t%e e&*lo8ee79

  • 8/9/2019 Computer Science Project 12th

    71/75

    PROGRAM 2:Deci&al To Ro&a Nu&erical

    Algorit%&STEP 1 START

    STEP 2 Enter number num

    STEP 3 -- hund[]={"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"}

    STEP 4 -- ten[]={"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};

    STEP 5 -- unit[]={"","I","II","III","IV","V","VI","VII","VIII","IX"};

    STEP 6 Display hund[num/100] and ten[(num/10)%10] and unit[num%10]

    STEP 7 END

    Solutioi&*ort +a,a.io."-*u/lic cla## Dec2Ro&a*u/lic #tatic ,oi( &ai0 t%ro$# IOEce*tio !!&ai

  • 8/9/2019 Computer Science Project 12th

    72/75

    'uctioDataI*utStrea& i7e$ DataI*utStrea&0S8#te&.i-S8#te&.out.*rit09Eter Nu&/er : 9-it u&7Iteger.*ar#eIt0i.rea(Lie0- !!acce*tig (eu&/erStrig %u(799)99)99)99)9D9)9D9)9D9)9D9)9D9)9M9-Strig te799)9]9)9]]9)9]]]9)9]L9)9L9)9L]9)9L]]9)9L]]]9)9]9-Strig uit799)9I9)9II9)9III9)9IC9)9C9)9CI9)9CII9)9CIII9)9I]9-

    !"Di#*la8ig equi,alet ro&a u&/er"!S8#te&.out.*ritl09Ro&a Equi,alet7 9

  • 8/9/2019 Computer Science Project 12th

    73/75

  • 8/9/2019 Computer Science Project 12th

    74/75

    'uctioTe&*erature o/7 e$ Te&*erature0-5u6ere(Rea(er /r7e$ 5u6ere(Rea(er0e$ I*utStrea&Rea(er0S8#te&.i-S8#te&.out.*ritl09Eter te&*erature i el#iu#9- !!acce*tite&*erature(ou/le te&*7o/.co,ert0Dou/le.*ar#eDou/le0/r.rea(Lie0-S8#te&.out.*ritl09T%e te&*erature i 'a%re%eit i# 7 9

  • 8/9/2019 Computer Science Project 12th

    75/75