computer programs.pdf

18
= uwpo!'tL l*n*hl'x; dAA v111"Yrba*Q 11 t ir* n"o I Lnrx *? pr,r[,tie. ct&-gl e uoid roa'{n{ I ( ' ** bear obJ ; rrm rwrw'bsnr(); ebi, qatnurt1; $rI 'vd*'Prwmil; qu ) uetd- $clruemf) t S(Anna..gc: rt,etu g}en:at {cgek'n'r'id; 9td.an,a)..'Pi** (" {*rh' ro* weX"$; ^A = sc'nLYxhv(); K ; e*terk h); pubtt t int F ' ft'* ;eq ( t_ $neCk 0v* trarn) f.:0,' 141 {:Ai \ in"t"t=liazh;i+r1 s+ = u j 4 Lt==vumv) L c4 +,, btcuk; a J ((s l*) LOnfrf\jJ,{,/ t ((> r,l*r,da bxnat"; t i4 Cc==f) yet wn 7.) ekt n*ktun A; Pu,talM vaLd, fusPum() L rruu x'xi .{ L6 (y==l) rtl 7o /^( " nattntb c*'b t t\4'4"4f Ll.,r.u/'"t ; okt sop|n ('' rwrnbc',- n N0T ht'Lrrfld"a^") ) 3 1 1 - *

Upload: romario-tim-vaz

Post on 18-Feb-2016

253 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Computer Programs.pdf

=uwpo!'tL l*n*hl'x;dAA v111"Yrba*Q

11t ir* n"o I Lnrx *?

pr,r[,tie. ct&-gl e uoid roa'{n{ I(

' ** bear obJ ; rrm rwrw'bsnr();ebi, qatnurt1;$rI 'vd*'Prwmil;

qu)

uetd- $clruemf)t

S(Anna..gc: rt,etu g}en:at {cgek'n'r ' id;

9td.an,a)..'Pi** (" {*rh' ro* weX"$;

^A = sc'nLYxhv();K ; e*terk h);

pubtt t intF

' ft'*

;eq (

t_

$neCk 0v* trarn)

f . :0, ' 141 { :Ai \

in" t" t=l iazh; i+r1

s+ = u j

4 Lt==vumv)L c4 +, ,

btcuk;a

J

( (s l*)LOnfrf\jJ,{,/

t ((> r,l*r,dabxnat";

t

i4 Cc==f)yet wn 7.)ektn*ktun A;

Pu,talM vaLd, fusPum()L rruu x 'x i

. {L6 (y==l) r t l

7o /^( " nattntb c*'b t t\4'4"4f Ll.,r.u/'"t ;

oktsop|n ('' rwrnbc',- n N 0T ht'Lrrfld"a^") )

311

- *

Page 2: Computer Programs.pdf

Data Members:

Str: To store a string. I

Revs!: To store the reverse String

Member Functions:

void getStr(): to accept the string

void recReverse(int): to reverse the string using Recursive

Technique.

void check() : To display the original string, reversed string and

check whether the str ing is palindrome or not.

, Specify the class Revstr giving details of all the member functions. You

need to write the main function also.

i m 1i ofri" !'"il)$-fflfr {$ r:{it*.crt

l: r-t.L l.t,{, l: * j.,:t ri'i.'}, ri!

tl . r

tnt A?L|J { 3t ,

9eannP'^-t t ' ' rd Cn:0. t l . t l t

*t { r r"m>l}

{L-_D)

uJt;tU, ( t,< mm*l)i7' d,n*= atI iJ;

L++ )?J

$s = dn r#d;

3l r

L,( (nm:: i )ILdnrdC;

l ,

s*l',;r* {,#n} r

L Lwx" C.d- , iw n *)

&&,36 ." 3

r0;

L

Page 3: Computer Programs.pdf

.d

3t " twL

Iq

dfiA Fin^dJrta>o

{. Lrrh n, *

Fit't^atWt 0L tn=-D, n*D;3

fy egetlvt*x{.W*x, ivt't'V} I

t M:Tt l l= l { ,L^b lz- = fWdA , rr)e* & r V) ;

_ ttdhuttth k iJ

il"tub FiW 9&ee ex.bea,afx F t rU*na*

' t - L^h r :$tz

Fi rva-qxzat ()

W-CI, K=0 , n*Oi

t1etflrLa*l O* X, LnL fL , LfL ^

lL=%tV=^,

'6brff d8W&exh1L;

z=E )

x) z)

e d (g?n rt, "Vr*Jn^?h,'U"rn

Vlr.A ( z?a ,FI x> *\

,vg

,t!'&Wa1*z-;

t

,*A*gr ruird"dJ;o

L,

/3'S"v. mfs

{@

t&&, &&f'N& a lV ) W ?'g; 'ny*.7&)

Ftxdfrt*ru s&j e, ttr'sw f rv&naw {\ U r ''

,u #. * s{1. qe*ak L^l in{i

ti,lefudwaA efo1 . tnau.l fiw&.€{Fucet{);L^.r L -- oto6, qq.L/nary (nt tnfu nS);

\ gopt* v .,J talu

. {?

v,

Page 4: Computer Programs.pdf

tr)ate :

QUESTION s

A l ibrary issues a book on rental basis at a26h cl ' t txge un the cpst pr ice oi the bi-r ,rk pet 'd. t 'v. As pc| t l re

rules of the library, a book can be retainecl for 7 days without any fine . If the tiook is rctut'ttcd aitct' 7 tlrtys

a fine will also be charged for the excess days hs per the chall gii 'eri below' .

Number of excess daYs1to56to10above l0 daYs

Design a class Library and another class

Class name

Data memberVinstance Yariablesname, author

p

Member functions/methods

Library( String n, String a, double np)

void show( )

Class name

Data members/instance variablesdr

Member functions/methodsCompute (.. . . . . . .)

i^-:-ie per day (Rs.tl.0L)3.005.()0

,rpute tc perfortn the task. The classes details are as -givctt:

l , ibrary

string variables to store name of book and authors name'

price of the book in decimals.

parameterized constructor to assigl the paratnete.rs n to nanlc.

a to author and nP to P.displays the book details.

Compute

number of days taken in returning the book.

to store the fine.

parameterized constructor to assign values to ciata nlembefs

of both the classes.

calculates the fine for the excess days.

displays the book details along with the number of days,

fine and total amount to be paid as fine. The amount is

calculated as :(i%o of price of book * total no. of days ) + fine

u .tor and void show( ). Using the concept of

Specify the class Library giving the details of the constru

Inheritance, specify the class Compute giving the details of constructor, void fine( ) and void display( )

function. You do not need to write the main( ) function. IISC 2009]

void fine( )void display( )

E rTTl lIiFF r,F.X-.Ff,lfltllG,r.:€L. A.S, FG

I

I- - i .*

il ;III 'IIiIIIIitII

lt

I

149,,."

Page 5: Computer Programs.pdf

fw? t

i f r , t

! o,t*t" ' l \r \* .Sl1.1\ )

f t ,

. )ivr t t , 1;

, \ , . / c n ' i+1)L --4, lz- /*\J ) \'

- i - rx (3C' , 1t7c) J++)nL/ ' J - , / J

t. r r : l = l ;6eaq r J\ I

$^-- 3 ;

'^qrd ,f . ll o] Iro,{r-:u.i.rf.*

r - i " ! i

l r r t - j i

- :

,y,,b ,t, 2 ,D{11 '

I

t lt l

l r

4v4

n

7.tAfz(j"l/

ff

D-fv

) j

fe**,.rLi,a\;

l?

t2i - l

nr 3;

\

I

t , -

'

J

1J

i r f i t ' '

iI

tr^t, 'Lr

I l,

ln, { i - . t l ' r4f \ ' rt\i

a

a l f , ' .[ -

ai {-,

r - \^^a \ r I0nyt i \ i

1 , - r ' , ' L. l -n- ' , l t+)\

J- ' j t

b.re{\ ' f#*(t ** "{ t t*- fkr l

\ r irJ '

I3

i

\0r , L{" : o1 \ { f^ ' tu*\ . ,\ ' r \ , ; dn' , 1 ' { - i '

'b t* ,1 ' , i1 r4

" L to\10'4,,

( ct"t:" t'Y"- I \'spt t "n \ l l

IJ

rl'r rl\ ,

't

J

Page 6: Computer Programs.pdf

Y.tT

c a"L( \

r\I 0r ( L=uit

{

tr$Lrl

r '.n

v

Q-{M j L*+\

*3"0t $d^,1*a\

u{ LL: = i)t to 'wwtoL' t

,bfrL"= L ' ;<= As\f l t t l \ i ) , z++\t ,{ [ru*tti]til

ol,L = =m\

t&-Ufr\*,* * I!t

Y

t t { ffi"1"4'4^L,

S\I Yra- ":

=*s")q unr\ t ati lti);

! \) copfi* [s* 4 gi;.r,ru,t'

-I: 3 ,* {-

4n\ulns"L: q 4 rt'tm!

t \- N-*[-z I ] 'ii

i,,J t]\ t : 8 l 'U '31r!:**:*.

tcl rltl

$ urvt\ : o' 1n'n-\

+ ax':' [ilLj1j ^ A ,', ]-{r-0* , nfi t ntn*s(Irv\r -

-,'-'(ilJu^^- lu Lvrtt- E cdp W- dfuL,\.,w"u$! .\.J '-,f '- \ opvvr-a-,.* = " +\vl\^\y

, c.xie-x"{i-A- Vex,,wW1 QL

\

P suf^ () ' /

, LLa-Q- rurts'P ( \ iwaLq*rt- [ ;P ob!= vtr-u

, \ $. . -nr \ ,r^'Utr' qcli) ; obi -':Lr-rotrr

()',, phl - c'eu" t4

.J. i

\

let IL- t ;Lz-rn-\ iL++)U

t , '-t-\,^ , r i - t . r r f iA;Jt- 'tg"{ l ' t i3{Y}- t

)

Page 7: Computer Programs.pdf

9: The slope of a straight line is calculated as:

^ y2-y1*r =

*2-"1 t '

where (x1, y1) and.(x2, y2) are the coordinates of the f irst straight l i i re.

v4-v3and rn2 :

x{x3

. where (x3, y3) and (x4, y4) arc the coordinates of the second str;right line.

If slope of both the lines is same, then the lines are parallel to each other arr,lif the product of the slope is -1, then they are perpendicular to each other.

The details of both the classes are as:

Class name

Data members/Instance variables:

x7, y1-, x2, y2, x3, y3, x4, y4slope

Member functions/ methods:Point0

void acceptPoint$

void Show$

Class nameData members/Instance variables:

m1, m2

-D Member functions/ methods:void findSlope$

void DisplayQvoid CheckQ

Point

To store coorclinates in double typt,To store the slope of the l ine in doul '1,,type.

Constructor to assign 0 to x1, y1, r.),y2, x3, y3, x4, y4.To accept the values of the coorrlinatcs.To cl isplay values oft x1, yl, x2, v),x3, y3, x4, y4.Slope

To store the value in elouble ty1x.using the formula:

v2-v7 ^ y4-y3nr l=-- ; -=; ' tn?

x2-x1 x4-x3

To store slopes of both the lines.To show the magnitude of the slopt'sTo determine whether the lines art,parallel or perpendicular.

Specify the class Point giving details of constructor, function void Show$, declar,. Ivoid acceptPoint$.

Using the concept of inheritance, specify the class Slope by giving the details of tlrt'functions void findSlope$, void DisplayQ and void Check$. The class Slope is clerivc,lfrorn the class Point.

-, r/.1;...f ltri I : !

W,,UnderstandinglsCConputerScience I SZ0

(a)

(b)

ir

Page 8: Computer Programs.pdf

Prog. Tl-re ci istance benveen

Jt- l - .2)r+(\ '1-" f tAn alrstract class Point represents a poit"tt t-, tr a 2D plane while another cl:rss

distance is declared to help in f irrding ci istatrce betrveen two points ancl mid

ooint. The details of both the classes are as:

Class name : Point

points (r1. v1) arrr l (x2, r '2) i : ; calculartecl as:

Data rnembers/ Instance variables:

x7, y1, x2,

abstract void readPoint$ :

abstract void FindDistanceQ :void Showo :

Class name

Data members/Instance variables:midx, midy

Member functions/ methods:abstract void readPoint$ :

Member functions / methods:

To store coordinates in double type.

To store distance in double tYPe.

Constructor to assign 0 to x1l'y"1, x2and v2. 'roTo declare abstract type function. \r

To declare abstract type function.

To clisplay values of x1, Y1, x2 andy2.Distance

To store midx and midY coordinatesin double type.

To input values of xL, yL, x2 and Y2declared in the class Point.

To find the distance between poiuts(x1, y1) and (x2, y2) declared in theclass Point.To find the distance between points(*1, y1) and (*2, y2) declared inthe class Point. The rnid Point iscalculated as: midx=(x1+x2)/2 andmidy= (y1 +y2)/2.

To display values of dist, midx and

y7:dis :

Point0 :

(o)

(b)

abstraCt void FindDistanceQ :

void FindN{idPointfl :

void Show$ :midy.

Specify the class Point giving details of conskuctor, function'void Show0, declare

abstract void readPoint$ and abstract void FindDistance0.

Using the concept of inheritance, specify the class Distance by giving the details of the

abstrict class functions abstract void readPoini$, abstract void FindDistance0, void

FindMidPoint$ and void Show0.

The class Distance is derived from the class Point.

ct I\ fl r*'-* 4 J Lrttr

---24-'-'yf I l o-;

:--:Cill ^/vL

bJry

Page 9: Computer Programs.pdf

/

Date :Qti t , )s ' t ' toN 4A hlrrk intends to' | ' | tclrvailabledenominafionswiththebankaretr*ff i ;d;:%:iT:: i ; I j" ' .design a program to display the denominati

l1'ons of an input amount, upto 5 digits.

l)csign'a prograffr to accept the amount from the user and display the break-up in descending order ofdcnominations' {i'e' preference should be given to the iign"r, denominations availabre) arong with thetotal number of notes' I Note : only the denominations usld should be displayed]. Also print the amounrin words according to the digits.

Test your program for the foilowing data and some random data:Example I :Input : 14856Output : ONE

Denominations :

Example 2 :Input : 6043Output : SIX

Denominations :

o\L ic;6

i *

FOUR EIGHT FTVE SIX

1000 x L4500x1100x350xl5xllx l

TOTAL =TOTAL NUMBER OF NOTES =

ZERO FOUR FIVE THREE

+

14000s00300505I

14856

2l

1000x6=20 "x 2 =2 x- l -lx l -

TOTAL =TOTAL NUIVTBER oF NOTES =

Example 3 :Input : 2?5001Output : tNVeLm AMOUNT

6000402I

6043

l0

lrsc 20101

2t4.*'.:..:i ;-+rrr="oiri;,i.?.-r.l'*i*.;..i : j:'i,

Page 10: Computer Programs.pdf

QUESTTON 5

Thc cornputcr department of the agency of International Espionagemcssilgcs. The agency's spies have determined that the enemy encodes

is trying to decode interceptedmessages by first converting all

space). The ASCII values of A,6532122, then relerse this to set

chur;rclcrs lo their ASCII values and then reversing the string.

Frrr cxanrple, consider A_z (the underscore is just to highlight the<spircc>, r. are 65, 32. 122 respectively. Concatenate them to get2212356 as the coded messase.

Writc a program which reads a coded message and decodes it. The coded message will not exceed 200chi t r i tc lcrs. I twi l lcontainonlyalphabets(A . . . Z, anda . . . .2) andspaces.ASCl lvaluesof A.. . .Zare65 . . . .90 and those of a. . . zare9l . . . . 122.'lbst your program for the following data anil some random data.

Sample data :

Input:

Flncoded Message:

23 t2t7 98623 t0 I 9950 I 81 231 923 t0 I 8 1 17e27Output:THE DECODED NIESSAGE :

llave A Nice Day****

Input:llncoded2.1 5l l0

Output:

l 1 50t7 82-?5 I 1 t2L799r|801 5 62340161 t7 |14 I 148

.I'IIE DECODED MESSAGE :'l'ruth Always Wins' i **

(t should be capital ietters) lrsc 2fi)41

Answer:

*18 : rr,,,.,,,::r ;:-rt;.ir;:it:

Page 11: Computer Programs.pdf

utEslor.r +

imPot"tt 4*o uti(. *;

elass *enarniYqat(on

dVoi& .f i4&|n()

| $Y\,.e u'^1'Yr,o0j

tvtL 0&[1 3 | tOOo, boq^l?O ' lb) f r ) ' lo ' 6 )L)t t '^

swi^f la$2[]={" ; t r^H'5-rw0",1"fHl tLY"t* . ouN\N9"}

U

kanrw rc * wtlr. {rfinne^ {frg *txrvJt ?i.^,

S 6sre'''

0 (JJ' Px'tv\*0t\ ( " Er'&zu &to3 rurnn'ban"!

' LnX ?? : ge 'n-cx"t'$*tt(); s

fiot { bn* b*0 J L4'"M irur.r#I'|^t i* +}

t g dhr\*ro

Lnt fi = wf a*tLiltV\

Lb t$\ .=F)t

(oPa,; . tusdl \ l+"?r:. h "1, nPt[iJ

3- tC

/ r (b*

/*-)-

\g)*P*

(trrrr = gnrnt"6)

-)p'" + b *" = " + o"1ilrr b)'i

.3B op QJ^ lt r*rw) j

sf Pu!\q L -- !*Y '6 Nk'fl^T cd; \

\a ( ' tp Vo ; ' r , r ' $ 'enAtt ' ( \ ' t t + )

sop',ra" ,[ar"*Ls &on*.-]- 'u* [" "+ t" Lh,oeoAtt])] +" ')

, ia

-z-i

Page 12: Computer Programs.pdf

. lCl lt

,1 ' : ; iur i r l t ' errcr .vpf ion s\ jstenir a l l re of t l ie shi f t cai l be i i lShi f t Value' should appear) .

i lses a shi f t ing pr.occ3: (r , l i i ie c i l ic l idr i ! ; i i<t l ie rauge rr f I io 26 i r . , l ! , , : r : l r . lu", . ,1*, l i "" . , rO

i

iJ

For exainple, Shi f t 7 means that A=U, B=V, C=!V ancl so on________Text: A B C D E F G H f I K L M N O p e R S T Li V vV Xy ZCode: U V !V XY z A B C D E F G H I J K L M N o P Q R S TAn extra space is added to the end of the.string. To 'rake

thi.gs a Iittle moredifficult, spaces withinthe otigi";ri"*t ur"."pru"ed with ee before th-e textffi$itft[oouble a (aai;"'

'"r".,"ail;';o i.,grir], word endsAdditionally, the .*""d

,message is printed in blocks of six c'aractersseparated by spaces. The last uro-"ct nright .ot .orrtuir., "i"" "trur".t"rs. write aprogram that takes the coded text (ress than 100

"r,ur*t"rr), the shiff valueand prints the decoded original t"*tl-y"o,,, program must reject any

^on_varidvalue for shift. Assume alicharacter" ur" in upper case.Input coded rext : . UHINBYLKKeCHHYLKKShift : 7Decoded Text : ANOTHER WINNERInput coded text : RUIIGGEVGGBKSAGGShift : 11Decoded Text : BEST OF LUCKlnput coded text : RUIIGGEVGGBKSAGGShift : 29Output : Invalid Shift Value

ZERO FOUR FIVE THREE

= 6000=40=2=l

= 6A43=10

frsc 20031

[rsc 2010]

Input :Output :

6043SIX

Denominations : 1000202I

X

.x.

xx

62II

. TOTALTOTAL NUMBER OF NOTES

Example 3 :Input : 235001Output : INVALID AMOUNT

.2is

Page 13: Computer Programs.pdf

Quest ion 1 "

Given two posit ive numbers M and N, such that M is between 100 and 10000 and N is lessthan 100' Find the smallest integ6r that is greater tfran M and whose digits add up to N.For example, i f M= 100 and N= 1 1 , then the lmallest integer greater tnai t oo whose digitsaddupto11is119.write a program to accept the numbers M and N from the user and print the smallestrequired number whose sum of al l i ts digits is equal to N. Also, print the total number ofdigits plesent in the required number. T1e program should check for the validity of theinputs and dispray an appropriate message for an invalid input.Test your program with the sample datalnd some random oata:Example 1INPUT: M=100N=1 1OUTPUT: The required number =119Total number of digits = 3

Example 2INPUT:M=1500N=25OTJTPUT: The required number = 1699Total number of digits =4

Example 3INPUT: M=99N=1 1OUTPUT: INVALID tNpUT

Exampte

Input z 6043Output : SIX ZERO

Denominations :

FOUR FIVE THREE

1000x6=20x?=

2xl=lx l=

600040

2I

6043

10, TOTAL NUMBER OF NOTES

Example 3 :

Input z 2)JA0lOutput : INVALID AMOUNT

t t4

TOTAL =

IISC 20101

Page 14: Computer Programs.pdf

I / 4

: . .qv.. : l . t . r : - ,

i.i:ff S:,':ff'J"",:'rf1;:i.ll5?']"r?Tifffi_r;ction i e Finding th" r,.,tu." dare n days arter thelr'::ilrr"*" number of days berween the current date and date on which a prsject ends.

lii fi"['Ji:ilri,:l"k;"::it,iT*;!J:i-',1,,T",ftI?"j ;'"f:i:,ffi:1,1," 32 you may assumeconverted to its equivalent iate .,r^#. Date numb", i, thit.li*u:rtllcufations easy each date can beand the given date (dd-mm)

uate number is the number of days between 1,t January (01_01)Example: Date (dd_mm) Date Number

01_01 120_07 2002_a2 3303_03 62

some of the tunctions/*"th"d:1o;"f* date are ,no#Lro-,Class name : ddteIqIEData membery'instance variables :

dd : davmm : month

Member functiony'methodsdate (int nd, int nm)int datetod","""*.?i , ::ffilT::"r::t::^ii: ld,,* = run

date datenumbertodate ( int dn )

returns the date number equivalent to the current dateobrect.

tr*" the date equivalent to the given date number

Class name : Numbers

ll

date futuredate ( int n ) : retu's the date that occurs n days after the current dateobject' you may assurne that the future J"r"i"'r u" i"sp"'i* the class date -giving the details of the -:::ffry'Jfi-.ro*

.d11" (int nd int nm), intiff:"#.#H:,,13,'* *n:*]l*; flJlli**#lh y.u may ;;;_u,ha,,he,/

r rrvr wrrlc: ure matn tunction. VSC_ 200gi

,.c:-:tstii"f't: z8" A class Numbers contains the following data members and member functions to.check for triangular numbers.

(A triangular number it fot^;J;; ihe additior, "i"

;;*",i"" ,"i;;"'J'r"tegers starting from 1.)eg.7+2-31+2+3=6'1.+2+3+4=19

7+2+3+4+5=15Therefore g, 6, 10,5 are triangular numbers.

Data Members:

Member functions:

void gehrum$int check(int)

speciry the class Numbers "#f

al',TilJ?n"The main functtbn need noib" ;;;;;."

rnteger to be checked whether it is

- tto accepf integer n.to check if n is triangular.to. display rnessage ,iheth", n is triangular or not.functions voi d ge rn um fl , int

"n""t 1ir.,ty i.uJ .l"rl'olr"J""* f f

triangular or not.

.e- J

Page 15: Computer Programs.pdf

il h cLa-vs/i

16u'*'ru

-l^* 4 unn, drlf '-C uo'ft",rtd;[y

C*"Ll-s'

-n ?

CLa'\,6 Y Wrwz '1/Wod;$d.

fu&* Yw*b*Ato 2 6h^ua & "tfrT

i

X"-) 6 loutw'W4ttr"o 'A

votd' ruAq ) a-LLTt eL'*z 'ff"t"oa'<- \

uuod P e'^ C i "b' c'l^ol ;f:r:ffi" U!*::Sffird d"/.''o^y{t 'sbi7

voLd balr-,od;0A*, dti*q 4'* ofd#''L' - , o U t ) . -oo0,, . , f t :. o / l , t o t l

-$usi'hiw "qn{ "tuP%

cJ"**d ,sbiq" ^ ,Cht^"+rn 'sf"-"''1, "

veid, &"^4tL) -) 1 '""-tlnce t;L '-l'oro'tz'uT"' /*, d o*:g*nJ at^sg*d

"W "-P*'*b!-- *l;L b""!

di*o'n'*- 4 z me*a aLua'i

1 -:;: Xn ",o^n{u" '

Vn* ,r*n1y *o w'd'bu -fu '^a-UL -#^*^'ttt-, "'04n^

' .:,

- i ii i

' l ' ,t l

-JJ

Page 16: Computer Programs.pdf

lt* $ LtcJk 4 Lk c!..a.*s L',,,rLlVar n,,A

Aol,,t'

/?^

l_"ya^6 A.[atu""

YWtuLbuq

Wl I YL

f "i l i / l

F I t t tCt tY LaK

; : t t ; f . , , / t , t^A/ AI TI I TI I I I A I / L

| ^

jJ L I L n / . / t / v L l_

aLa

T*EitLt.^,l . '

: l , la.- r ( - '

{ - '/J -\ c:^:' i.,v ( L ({ I ( ' l tknt t , tN

/i,,o!fl,r,,,t

tu'^

; 'twtnXu't voLtoLt"t Lr 'Sb*" nuvwbua

lVlu*bu.o 'ltrn,twnz tctD^ tc, o,h* c to Mt (1

f'*fu\AorO : Grtstn"Lo't to 6rcn

iruh Lf*r 'no^.n'Fac'id O ?::t"S'o*

A^**r#-{6,*t*r

/ ' )nAl

eXP'n /\avw: T'id"{i4u'oL

Page 17: Computer Programs.pdf

. r ' f i?**t 'F J ' , - 'U'Pa nr'

\

+f"--1 ) :

{rA uv'O ''\-{'2-

r " f ) ! , r i j ,_-r . :

/ P'a-t-c+,n "ju

^GYWefx-c'x

Aouv'\

Clt'\4

gPzrcf tcM,l

.b r'tt *

v \dd"

v oid

t\A 6 o A^P

" JYLaAx*KvJ

f i**Ywwbuz' n t, Atrr*]Mt0-r ' t-a-K't2^9"{L

' a^hLJ LJ + &ouLl ' NL*"no'"" un""n'u :fffikmr;;:::,,3

I

:"."; oLKLtl"

A^ ,Y{rnol t . -

u, ; t ; r t ;g- #,- ilvlu,,,J*;';:;

vo€A s'c),n|j;l tr;mi'm'dln*''--*

w"&af^-

e& , '^,?^vW ^"*h;',#.nwC) i loT**^

ffi#:;:f#r'W'o*r"*u "*c :*%+h*- o!'^' *iZ'uPt

1o*^do*-

tf.- \.1./t n ;,n r'rubW nkS

" l l l . ot .

ebF"f f iJ

Page 18: Computer Programs.pdf

QUESTIONA.class Salesrnan defines

ruumber, name of the item'

Class name

Data members/instance variablesname

address

Member functions/methodsSalesman( ;

void readDetails(String n, String ad)

void Show( )

Class name

Data members/instance variablesbillno' qtY

price, Psalespname

Member functions/methods

void readDetails(int b, int q' double p)

void readDetails(double s, String pr)

calcu

the perlonal data of a salesman while another class Sales defines the bill

numberof i temssoldandpr iceofthdi tem.Thedetai lsofc lassesareaS:

Date :

Salesman 1

string variable to store name salesman'

string variable to store address'

constructor to assign blank to name and address'

to assign 'n' to name and 'ad' to address'

to prini values of name and address using suitable headings'

Sales

integer to store bill number and quantity'

double type to store price and previous sales amount'

string variable to store name of product'

to assignto assigno

to billno, 'q' to qtY and

to psales (Previous sales)

to price.'pr'to pname

furrnula-::

'p'and

t Price (P)

void Show( ) : to disPlaYtotal sales

x quantitf (qty) l+ previous sales (psales)

uulu., of pname, trillno, qty' price' sales an

(a)

(b)

made by invoking suitable function'

Specify the class Sa!1ma1 givingdetai lsofconstructor,functionsvoidreadDetai ls(Stringl

Siring ad) and void Show( )' 'I

:::J;'Jtr#or inheritance specrrv ":^l'l':-::l::lJ.tilii:"TffiiJ'1"":ff1'":ff;;y#b:ffi|il:T,:l ilffiffi;, 5iia readDetans(doubre',-st'i"g pr), doubre carcurate(

ffiil;i';.-Y;; do not *"gio I:!" 91 113'Tg:*91-Answer: