0% found this document useful (0 votes)
12 views7 pages

X Board Project Questions

The document outlines a series of programming questions related to class definitions, member functions, and various computational tasks. It includes specifications for defining classes such as 'Salary' and 'Library', as well as methods for input, calculation, and display of data. Additionally, it presents problems involving prime number checks, Armstrong numbers, and sorting algorithms, among others.

Uploaded by

pixelperfect257
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)
12 views7 pages

X Board Project Questions

The document outlines a series of programming questions related to class definitions, member functions, and various computational tasks. It includes specifications for defining classes such as 'Salary' and 'Library', as well as methods for input, calculation, and display of data. Additionally, it presents problems involving prime number checks, Armstrong numbers, and sorting algorithms, among others.

Uploaded by

pixelperfect257
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
You are on page 1/ 7

Cl

assX
Comput
erPr
ojectQuest
ions

Questi
on1
Defi
neacl
assSal
aryhav
ingt
hef
oll
owi
ngdescr
ipt
ion:
Dat
aMember
s/i
nst
ancev
ari
abl
es:
pan : t
ost
oreper
sonal
accountnumber
i
d : t
ost
oret
hei
d
t
axi
ncome : t
ost
oret
heannual
tax
abl
eincome
t
ax : t
ost
oret
het
axt
hati
scal
cul
ated
MemberFunct
ions:
Sal
ary
() : def
aul
tconst
ruct
or
v
oidi
nput() : t
oacceptt
hepannumber
,nameandt
axabl
eincome
voi
dcalc() : cal
cul
atet
het
axf
oranempl
oyeeaccor
dingt
othegi
ven
condi
ti
ons:
Tot
alAnnualTaxabl
eIncome TaxRat
e
Upt
oRs.100000 Not
ax
From Rs.
100001t
oRs.150000 10%oft
hei
ncomeexceedi
ngRs.
100000
From Rs.
150001t
oRs.250000 Rs.5000+20%oft
hei
ncome
exceedi
ng
Rs.150000
AboveRs.250000 Rs.25000+30%oft
hei
ncome
exceedi
ng
Rs.250000

v
oiddi
spl
ay() : Out
putt
hedet
ail
soft
heempl
oyeeaspergi
venf
ormat
:
PanNumber I
d Taxabl
eIncome Tax
_
___
___
___ _
___
__ _
___
___
___
___
_ _
___
_

Quest
ion2
Def
ineacl
asscal
l
edLi
brar
ywi
tht
hef
oll
owi
ngspeci
fi
cat
ions:
I
nst
antv
ari
abl
es/
Dat
amember
s:
i
ntbn:
tost
oret
hebooknumber
i
ntphno:
tost
oret
hephonenumberoft
hest
udent
St
ri
ngname:
tost
oret
henameoft
hest
udent
i
ntday
s:t
ost
oret
henumberofday
sret
urnedl
ate
i
ntamt
:tocal
cul
ateandst
oret
hef
ine

Membermet
hods:

Comput
erPr
ojectCl
ass-X(
St.John’
sSchool
-Jaunpur
) 1
v
oidi
nput
():
toi
nputandst
oret
hedet
ail
soft
hest
udent
v
oidcomput
e() :
tocomput
ethef
ine,
Thef
inei
schar
gedont
hef
oll
owi
ngbasi
s:
f
orf
ir
stf
iveday
s :
Rs1.
50perday
f
ornextf
iveday
s :
Rs1.
75perday
r
estoft
heday
s :
Rs2.
00perday
v
oiddi
spl
ay() :
todi
spl
ayt
hedet
ail
sint
hef
oll
owi
ngf
ormat
:
BookNo. PhoneNo. Name Noofday
s Fi
ne
_
___
___ _
___
___
_ _
___
_ _
___
___
__ _
___
Wr
it
eamai
nmet
hodt
ocr
eat
eobj
ectofacl
assandcal
ltheabov
emembermet
hods.

Quest
ion3
Wr
it
eapr
ogr
am usi
ngaf
unct
ioncal
l
eddi
spl
ayWor
ds(
)todi
spl
ayt
hear
eaof
:

i)voiddispl
ayWord(Str
ings,
charch)withoneStr
ingandonecharact
er
par
amet er
countthefr
equencyofcharact
erparameterchi
nthegi
venStr
ings.
Example:
Inputval
ueofs=“ WELCOME”
ch=‘E’

out
put:
frequencyof‘
E’i
s=2

i
i
)v oi
ddispl
ayWord(Str
ings, i
ntn)wit
honeStri
ngandonei
ntegerpar
amet
eras
i
ndex
pri
ntt
hepartofstri
ngsf r
om givenindexnt
olast
.
Exampl
e:
Inputvalueofs=“WELCOME”
n=3

out
put:
Par
tofSt
ri
ngi
s-COME

ii
i
)v oi
ddisplay
Wor d(
Str
ings1,Str
ings2)wi t
htwoStri
ngparameterthat
combinesthe
twostri
ngswithaspacebet weenthem andpr
intt
heresult
antstr
ing.
Example:
I
nputvalueofs1=“WELL”
valueofs2=“DONE”

out
put:
Resul
tantSt
ri
ngi
s–WELLDONE

(
UseLi
brar
yFunct
ions)

Quest
ion4
Desi
gnaclasstoover
loadaf
unct
ionpri
me()asfol
l
ows:
(
a)bool
eanprime(i
ntn)– wi
thonenumberasar
gumentandchecknumberi
s
pr
ime
ornot
.Exampl
eofpr
imenumber
s:3,
5,
7,
11,
13……
Comput
erPr
ojectCl
ass-X(
St.John’
sSchool
-Jaunpur
) 2
(
b)bool
eanpr
ime(
intn,
intm)– wi
tht
wonumber
sasar
gument
sandcheck
number
s
ar
etwi
npr
imeornot
.Exampl
eoft
winpr
imenumber
s:(
3,5),
(11,
13)
…….
.

Quest
ion5.
Wr
it
eamenudr
ivenpr
ogr
am t
oper
for
mthef
oll
owi
ngoper
ati
onsusi
ngswi
tch-
case:
(
a)Ent
eranumberandchecknumberi
sanArmst
rongornot
.
AnArmstr
ongnumberi sanumberwhi
chisequalt
othesum oft
hecubeofi
ts
di
git
s.
Ex
ampl
eofanAr
mst
rongNumberi
s153=1+5+3=153

(
b)Pr
intf
oll
owi
ngpat
ter
n-*
*
#
*
#*
Quest
ion6
Wr
it
eapr
ogr
am t
ost
ore10namesi
nanar
ray
.Ar
ranget
hesei
nal
phabet
icalor
der
by sor
ti
ng.
Pri
ntt
hesor
tedl
i
st.Takesi
ngl
ewor
dnames,al
lincapi
tall
ett
ers[
Use:
Sel
ect
ionSor
t]
Exampl
e:SAMSON,
AJAY,
LUCY,
etc.

Quest
ion7
Wri
teaprogr
am t
oinputani
ntegerar
rayA[]ofnsi
ze.St
oreal
lev
eni
nteger
sof
ar
rayA[]f
rom l
eftt
ori
ghtandal
loddi
nteger
sfr
om r
ightt
olef
tinanot
herar
rayB[
].
Pr
intbot
hthear
ray
s
Exampl
e:I
fA[]={
3,6,
9,
5,
12,
14,
8,
18,
7,
21,
10,
4}
B[]={
6,12,
14,
8,
18,
10,
4,
21,
7,
5,
9,
3}
Quest
ion8
Wr
it
eapr
ogr
am i
nJav
atoacceptt
henameandcont
actnumber
sof25peopl
e.The
pr
ogr
am shoul
daskt
heuserf
oracont
actnumberandsear
chf
ori
tint
he
cont
actnumber
sar
rayusi
ngt
heBi
nar
ySear
cht
echni
que.I
fthenumberi
sfound,
t
hent
hecor
respondi
ngnamei
sdi
spl
ayedot
her
wiseapr
operer
rormessagei
s
di
spl
ayed.

Quest
ion9
Wr
it
eapr
ogr
am t
oacceptt
henameandwei
ghtof20ofy
ourf
ri
ends.St
oret
he
wei
ghti
nadoubl
ety
pear
raywei
ght[]andt
henamei
nSt
ri
ngt
ypear
rayname[]
.
Thensor
tthename
ofy
ourf
ri
endsi
nascendi
ngor
deroft
hei
rwei
ght
sandf
inal
l
ypr
intt
her
esul
t.

Comput
erPr
ojectCl
ass-X(
St.John’
sSchool
-Jaunpur
) 3
Quest
ion10
Wr
it
eapr
ogr
am usi
ngaf
unct
ioncal
l
edar
ea()t
odi
spl
ayt
hear
eaof
:
a)Equi
l
ater
alt
ri
angl √3/4)s2, s=si
e=( deofanequi
l
ater
alt
ri
angl
e
b)I
soscel
est
ri e=¼b√4a2–b2, a=equal
angl sidesofat
ri
angl
eand b=base
c)Scal
enet
ri
angl
e=√s(
s-m)(
s-n)(
s-p)
,wher
es=(
m +n+p)
/2,
wher
em,
n,p
ar
e
t
hreesi
desofat
ri
angl
e.Di
spl
ayt
hemenut
odi
spl
ayt
hear
eaasperUser
’s
choi
ce
Quest
ion11
Acl
assHi
Arm hasbeendef
inedt
ofi
ndwhet
heragi
vennumberi
sanAr
mst
rong
numberornot
.Somemember
soft
hecl
assar
egi
venbel
ow:
Cl
assname :Hi
Arm
Dat
amember
s/i
nst
ancev
ari
abl
es:
n : i
ntegerdat
atost
oret
henumber
.

Memberf
unct
ions/
met
hods :
Hi
Arm () : const
ruct
ort
oassi
gn0t
on
Hi
Arm(
inta) : const
ruct
ort
oassi
gnat
on
i
ntsumAr
m(i
nt):t
ofi
ndandr
etur
nthesum ofcubeofdi
git
sofanumber
v
oidi
sAr
m () : t
oinv
okesumAr
m ()andpr
intwhet
hert
henumberi
s
Ar
mst
rongornot

Thenwr
it
ethemai
n()met
hodt
oinputanumberandcal
ltheabov
efunct
ionsas
r
equi
redt
ocheckwhet
heri
tisanAr
mst
rongnumberornot
.
[Not
e:AnAr
mst
rongnumberi
sanumberwhi
chi
sequalt
othesum oft
hecube
ofi
tsdi
git
s.
Ex
ampl
eofanAr
mst
rongNumberi
s153=1+5+3=153]

Quest
ion12
Ent
erI
ncome&calcul
atet
het
axf
or10empl
oyeesaccor
dingt
othe
gi
ven/
inf
ormat
ion:

Taxabl
eIncome TaxRat
e

Upt
oRs.100000 Not
ax

/
From Rs.100001t
oRs.150000 10%oft
hei
ncomeexceedi
ngRs.100000

/
From Rs.150001t
oRs.250000 Rs.500+20% oft
hei
ncomeexceedi
ng/
/
Comput
erPr
ojectCl
ass-X(
St.John’
sSchool
-Jaunpur
) 4
Rs.150000
/
Abov
eRs.
250000 Rs.25000+30%oft
hei
ncomeexceedi
ng
/
Rs.250000
Quest
ion13
Wri
tesepar
atepr
ogr
am t
ogener
atet
hefoll
owingpat
ter
nsusi
ngi
ter
ati
on(
loopi
ng)
st
atement
s:
(
a)Pr
intf
oll
owi
ngpat
ter
n
1
23
456
78910

(
b)Pr
intf
oll
owi
ngpat
ter
n
$
##
$$$
####
$$$$$

Quest
ion14
Thesum oft
wodi
stancesi
scal
cul
atedas:
Di
stance1=10f
eet
s24i
nches,Di
stance2= 5f
eet
s16i
nches
Sum ofDi
stances=18f
eet
s 4i
nches
Acl
assDi
stancehast
hef
oll
owi
ngmember
s:
Cl
assName : Di
stance

Dat
amember s : f
1,f
2(i
nteger
stost
oret
hef
eetv
alueof2
di
stances)
i
nc1,
i
nc2(
int
eger
stost
oret
hei
nchv
alueof2
di
stances)
Membermet
hods :
Dist
ance(
inta,i
ntb,i
ntc,i
ntd):const
ruct
ort
oassi
gnat
of1,bt
oinc1,ct
of2
anddtoinc2
v
oidshowDi
stance(
) :t
odi
spl
aybot
hthedi
stanceswi
thsui
tabl
emessage
v
oidsumDi
stance(
) :t
ofi
ndt
hesum ofdi
stancesandpr
inti
t.
Writ
eapr ogram i
nJav
atoi
nputt
wodi
stancesandcal
cul
atet
hei
rsum by
appl
yingpr
oper
Comput
erPr
ojectCl
ass-X(
St.John’
sSchool
-Jaunpur
) 5
adj
ustment
s.Di
spl
ayt
hef
inalr
esul
twi
thappr
opr
iat
emessage.[
Giv
en1f
eet=12
i
nches]

Quest
ion15
Desi
gnacl
asst
oov
erl
oadaf
unct
ionpat
ter
n()asf
oll
ows:
(
a)doubl
epat
ter
n(doubl
ex,
doubl
en)wi
tht
woar
gument
sandr
etur
nst
he
n n-1 n-2 1
sum oft
heser
ies,
S=x +x +x +…….
+x
(
b)v
oidpat
ter
n(St
ri
ngs)– t
opr
intt
heSt
ri
ngi
nthef
oll
owi
ngf
ormat
:
Ex
ampl
e:I
fs="
TIGER"
Out
put
:R
RE
REG
REGI
REGI
T

Quest
ion16
Wr
it
eapr
ogr
am i
nJav
atoacceptt
henameandr
oll
number
sof20st
udent
s.The
pr
ogr
am shoul
daskt
heuserf
orar
oll
numberandsear
chf
ori
tint
her
oll
number
sar
rayusi
ngt
heLi
nearSear
cht
echni
que.I
fthenumberi
sfound,
thent
he
cor
respondi
ngnamei
sdi
spl
ayedot
her
wiseapr
operer
rormessagei
sdi
spl
ayed.

Quest
ion17
Wr
it
eapr
ogr
am t
hatencodesawor
dint
oPi
glat
in.Tot
ransl
atewor
dint
oPi
glat
in
wor
d,
conv
ertt
hewor
dint
oupper
caseandt
henpl
acet
hef
ir
stv
owel
oft
heor
igi
nal
wor
das
t
hest
art
oft
henewwor
dal
ongwi
tht
her
emai
ningal
phabet
s,Theal
phabet
spr
esentbef
ore
t
hev
owel
bei
ngshi
ft
edt
owar
dtheendf
oll
owedby“
AY”
.
Ex
mapl
e1: I
nput
:Magi
c
Out
put
:ADI
CMLY

Ex
mapl
e2: I
nput
:Appl
e
Out
put
:APPLEAY

Quest
ion18
Wri
teaprogr
am t
oinputani
ntegerar
rayA[]ofnsi
zeandpr
intf
ir
standsecond
hi
ghestnumber
.

Comput
erPr
ojectCl
ass-X(
St.John’
sSchool
-Jaunpur
) 6
Quest
ion19
Wri
teaprogr
am t
oinput10di
gitI
SBNNumberandchecki
tisv
ali
dornot
.Fi
rst
checki
tshoul
dbe10di
gitaf
tert
hatgett
hesum ofbymul
ti
ply
ingeachdi
gitby1t
o
10f
rom l
eftt
ori
ght
,checki
fsum i
sdi
vi
sibl
eby11t
hennumberi
sval
i
dISBN.
Exampl
e: I
nput
:1259060977
Sum:
1*10+2*
9+5*
8+9*
7+0*
6+6*
5+0*
4+9*
3+7*
2+7*
1=209
Di
vi
deby11: 209%11=0
Remai
nderi
s0,
So1259060977i
sVal
i
dISBN
Quest ion20
Wr i
teapr ogram t oinputanumberandcheckCompositeMagicnumber.A
Composi t
eMagi cnumberi saposi
ti
vei
ntegerwhi
chiscompositeaswellasamagic
number .
Composi t
enumber :Acompositenumberisanumberthathasmorethantwo
factors.
Forexampl e:10
Factorsar e:1,2,5,10
Magi cnumber :Amagi cnumberisanumberinwhichtheevent
ualsum ofthedi
git
s
i
sequal to1
Forexampl e:28=2+8=10=1+0=1
THECOMPOSI TEMAGI CINTEGERSARE:
10,28, 46,55, 64,82,91,100

Comput
erPr
ojectCl
ass-X(
St.John’
sSchool
-Jaunpur
) 7

You might also like