Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
81 views
Computer Programs Class 12 Computer Science 2
Uploaded by
Nagappan Subramanian
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save computer programs class 12 Computer science 2 For Later
Download
Save
Save computer programs class 12 Computer science 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
81 views
Computer Programs Class 12 Computer Science 2
Uploaded by
Nagappan Subramanian
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save computer programs class 12 Computer science 2 For Later
Carousel Previous
Carousel Next
Save
Save computer programs class 12 Computer science 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 58
Search
Fullscreen
and call 4,Yee ae Explanation: Input number : 14 The digits are 1 and 4 formed by 1 and 4 ate (i) 197 is a Keith Number Input Number » 19; The digits are 1, 9 and 7 Tribonacei series formed by 1, 9 and 7 1, 9, 7, 17, 33, 57, 107, 197, (ai) Input-Number % Output Nota Keith Number} Write a program in Java to enter a natural @ natural number, where Ni tere N>100 and N=1000, th pee * natural numb 8: Print all the combinations of di fumber including the number itself, Each a se “vad Nar a Prato ample Input: Enter a number: 465 sample Output: 456 465 546 564 65 ost Sample Input: Enter a number: -712 Sample Output: Invalid Number Sample Input: Enter a number: 960 Sample Output: Invalid Number A triangular number is formed by the addition of consecutive integers starting: must not contain 761 Y combination should ap ‘ with 1 For example, 14+2=3 14+2+3=6 14+2+3+4=10 1424+34+44+5=15 are triangular numbers. Java to display all the triangular numbers from 3 t0 n, taking the Thus, 3, 6, 10, 15, .. Write a program in value of n as an input. Prog. 7: A Smith number is a composite number, whose sum of the digits is equal to the sum of its prime factors. For example: 4,22, 27, 58, 85, 94, 121 Write a program in Java to enter or not. Sample Input: 666 Sum of the digits: 6 + 6 + 6 = 18 Prime factors are: 2, 3, 3, 37 @ Sum of the digits of the prime factors: geata+G+nee Thus, 666 is a Smith Number. are Smith numbers. ‘a number and check whether it is a ‘Smith number a oe Statements and Scope5408) B J a r he EXPT en programs based on sing), gle tat ac N Of the fot ste @ POBFAM tO INUE and store w ing, | POUbIe D} int each number with its freq? Bers (y Arora tency in two different columng ™°Y: The outpen 2 Sele subs al Arrays Sample Input: should conan Pte variable in number ana and pelle ‘sample Output: GET {ey ‘Number Frequency 12 4 14 3 16 2 18 2 20 3 2 Write a program to accept a set of n int Bites rer 1 crt» tof nage (hon > e ae array, next lower number in the Teen the let cel pits centre and so on... . The process will stop wh ‘number wll be set in its appropriate cell. Finally, display the arty clara, “Assume that the memory space is less. Hence, you anomie aes : need to create extra array "Example: ‘Pr0g: , ina single dimensional jest number appears in the f the centre, next lower in Sie un, cea: 4 lee 31 145 ie it 1d og. 3: A bank intends to design a program to display the denomination of an input amount, to 5 digits. The available denominations with the bank are of rupees 2000, 500, 200, 100, 50, 20, 10 and 1. ign a program to accept the amount from the user and display the break-up in ending order of denominations. (ie., preference should be given to the highest Nomination available) along with the total number of notes ate: Only the denomination used should be displayed]. Also print ds according to the digits. the amount in eeRriei2 *106 ining boxes= 2° T= 2 ematiymber of Boxes: 140 set Camber oF cartones mpl yon a square matrix M1 {of ,, # GN reept thre different charnaye Mer 10. Saput shown from the Id be les. TF the 9 ; gecond Ch sind Character “# ‘Output: 3 2H? pee? Soe prample 2 Enter Size: 5 nput: First Character ‘$" ‘Output: Size out of Range fap? The result of a quiz competition is to be prepared as follows The quiz has five questions with multiple choices (A, B, C, D) with each question samying 1 mark for the correct answer. Design a program to accept the number of Participants N such that N must be greater than 3 and less than 1. Create a double dimensional array of size (N x 5) to store the answers of each participant rowswise, ‘Galoulate the marks of each participant by matching the correct answer stored in. 2 single dimensional array of size 5. Display the score of each participant and the Participant(s) having the highest score. lsc 2016) Example: If the value of N = 4 then the array would be: Participants Participant? =| = A Participant 2eats Lower THangular 5 Program in Java to input et 6 Salar Matrix oF not aa! 2 Ratt: A SCALA mate is g iia. se Matis is Scalar sre matrix is the matrix in why, - ih numb Pek a matrix of order n’n is called a Squeet Of equa Foe a program in Java to create a double gry at MmMber of co MAF the numbers in a cicular fashion (anne OA : on (ant oa aay of ie $5 retaking nas an input. The fi mag ing of the elomarr for example, if n=4, then n? an tart from outer 6, then the array is fi he is filled as; st Asquare matrix i the matrix in which number of rows has a matrix of order n‘n is called a Square Mate. Write a program in Java to create a double dimensic ocr sional array of size nxn ma SS eeipeaniiemmme fom 1 to n®, taking n as an input. Input n should be an odd number and fi ling, the elements should start from the central cell. $ For example, if n=5, then n?=25, then the array is filled as: (121 3 | 20 fe 3 [9 | 10) hw 6 Lotty 2, ye ‘ 18 [L541 4 i ae zeros? ype A rouble dimensional array of size nxn ‘matrix form jion (anticlock- wise) ‘with natural numbers from: -quals the number of columns. ‘agit: Write a program in Java create a di ‘and fill the numbers in a circular fashi 1 to 1?, as illustrated below: example, if n=5, then n?=25, then the array is filled as:: i BETA (0 create ap eu, te, orresponding! ce te Powe co shy: Disp ns Sample Input PY the [ss [33 [26 | a [si] 86 | a1 | 10 tat e417) a2 ole {4 0 [22 [4 | 23 | a5 Dy proeram in Tava t0 store the Gente Uhimnatr form) Avand Boe "™Nt5 in yy preaye and store the result in mamiy cf order 4 "4° ilforent mat KC. Display the fit the le dimen luce tonal f both the x can be multiplied only if the numb Mere s of Patino number Of OWS of the second mains. °f MMS of the ‘tat ada Sample Input: Matrix 4 Samp Ple Input: Matri =] trix B 6 | 3 [23] a7 (@) Write a program to declare a square matrix A [ ] [] of order N (N<20). (@) Allow the user to input positive integers into this matrix, Perform the following tasks on the matrix. (9 Output the original matrix. (@ Find the SADDLE POINT for the matrix. A saddle point is an element of the matrix such that it is the minimum element for the row and the maximum element for the column to which it belongs. Saddle point for a given matrix is always unique. If the matrix has no saddle point, output the message “NO SADDLE POINT”. (0 If the matrix has a saddle point element then sort the elements of the left” diagonal in ascending, order using insertion sort technique, All other should remain unchanged. = = "Test your program for the following data and some random data: iple data: Input: n=4 Matrix Al JI = Bus rayssorted Second array: B But suppose. 13 yc, % 3142 % 90, or gyn Oo Weemallest base for y (1 ale. The base we esenting thes le Data Tet samp! input! 12 (base 3)=5 (base 6) Input: x=10, y=A Output: 10 (base 10)=A (base 11) Input: x=12, y=34 Output: 12 (base 8)=34 (base 2) Input: x=123, y=456 Output: 123 is not equal to 456 in any base between 2 to 20 Input: x=42, y=36 Output: 42 (base 7)=36 (base 8) , 2 The manager of a company wants to analyze the machine usage from the records to find the utilization of the machine. He wants to know for how long each user, used the machine. When the user wants to use the machine, he must login to the machine and after finishing the work, he must logoff the machine. Fach log record consists of: User Identification number Login time and date Logout time and date =)mm/yyyy ante year. Find thesnutes the the an the PFOBTAM ON the fotloy, 8 ing | [Bape Bite Tay one (04/9/1998 THURS | oa [9911272000 [Sato TURSD WEDNE + » program should include 1 ‘phe PS the part jn day on the ISt January gf, alia pos aatare i828 2 by n arid yn, a wor weontains integers from 1 yo. 8 1 fal Ope sum of integers in any roy gM cach in © Trample, the following grid jos OT Stamn gee Pee ee hen rege 8 8 wonder Elmo is : square vals, eet [5 ~— as See Doe 2 fetes ee emp s pat wie a program to read n @<=n<=19) ang the vat values stored in the nd output the Bed represens swan gand Also output al he prime numbers in the gay ee imo dvisor For example, 2 3,5, 7.111 Het SS tobe pine ype ipstored at row index 0. and column index 0 and the set °! the given grid te. 17 js stored at row index 0 and column inde ext clement in the row ie. 24 Test your program forthe following data and some andom 4 . random data: se nb A cells and column Input: n=4 [a6 Bross 9 (3 Output: Yes, it represents a wondrous square Prime Row Index | Column |__ Index 2 0 3 3 3 o 5 2 3 7 3 i ii 3 a B 3 Z 15 anumber verte # a priene factor ree Dimenstonal AFFaY Of Order [mj nro create Dome Eetiod BoUNABEY ) 0 cal _ ve: Pe nts of the aa” x ounclary @ é Ira, and columns 4 i 8 8 go Tee comer 22, 0 unt? indary elements = 129 fis an int sample Outpt: Sass of 9 4 rs taining 10 oe ‘class Duplicate to pack the array containing 10 int =, Prog. 16: Define « 6 uplicate ‘elements from the sorted array), - a ee reece if dhe given array has the following sorted mumbers, oa 233444566 5 ifn=7,¢ ‘The resultant array should contain each element once. The outputs). ree 123456 A few = [Now pass the array to a method PackList () to remove the duplica G70 the resultant array. TL, 73) 17. Write a program to input a string str in a mixed case. Pass the ass, 18 Prog. 17 aify(String wed) that replaces each letter of the original st Waite « letter in the ASCII table. The replacement follows round robin s —_ follows letter ‘z’). c a For example, combi ‘Sample Input 1: AbD becomes CdeF SP Sample Input 2: Xyz becomes Zab p i. Create an object in main () and call the method modify (String w4) a... E enable the task. i l , Specify a class Display_word that accepts a sentence str. Pass it ' Longest( String wd) to display longest word of the sentence. displays the ASCII code of each letter of the longest word. Define the main() method to create an object and call the meth (Longest (String wd) ) to enable the task. For example, Sample Input: Understanding Computer Science Sample Output: Understanding ASCII codes are: U 2 85. A, : 110 ata Se 9.0 eIme Triplets OR ne4, ny 20 if NSS then 5, 7 6, 80 (5, 7, 11) are 4 they satity the 6) are at 4+2=9), 13 (746013) Prime numbers. Where =11). Here 1 646, 5.7, and 1 Prime triplets, ) are prime num 13) are not the prime triplets, 4211) and 13 (746213) are eee numbers, Here 7,11 an 43 50 (7, U1, 18) are the prime triplets ibers, Here 7,9 and 13 all are of prime triplets are:What 1s mes 9, Define the following: (@ Class variable (B) Instance variable (0) to, 10. Why is an object not passed to a constructor by value? 11. Differentiate the following: (a) Constructor and Method (®) Public and Protected specifiers (c) Default constructor and Non-parameterized construc (@ Built-in data types and User-defined data types 12. Explain the characteristics of a constructor, lor Prog. 1: A class Rearrange has been defined to insert an element li an array. Some of the members of the class are given below. Class name : Rearrange Data members/instance variables: al] : An integer type array, n : Size of array (integer), pos] : Position of insertion (integer), pos2 : Position of deletion (integer). item : Item to be inserted (integer) Members functions/methods: void enter() : To enter size, array elements elements. void insert() : To accept element (item) insertion and insert the elem less than 0 and not greater t void disp 1() : To display array after item void disp2() : To display array after item is void remov() : To accept the position of del index of deletion. It should not than n-1). Prog. 2: Class Convert has been defined to express digits of an inte The details of the class are given below: Class name : Convert Date members/instance variables: : zt : Integer whose digits are to be exP! Understanding Isc Computer Science-xilJ sr he Racing, mn. ee th A8 t tadions ant defined to calculate Calculates and returns the cos vfive of angle x 7 places after the decimal using the inte snes pee above when x is within the range otherwise if returns an error value of 9999999.9, wee: "+ Calculates and returns the value of secx by using he vale of cos x (remember when x isin radian and 0-< =9< =p then 1>=cosx >=0). a giving details of the constructor ouble cos(), double sec() only. You do not newta ase SoH the array Display a asa Collection ivin, ego) 4 Bens. Do no erie the ete ot Nas Been eine yi), ee Modity averwinstance variables perme Stores a st ven To store tony ctions/method. math giver funeti dO To ac od TD ACCePL the stein ord Manin, char) ea paint f Isplay the chan axeout(int) To reme pont We a chy and disy play thy To replace each For example, 88 distan ABCD” becom sciy the olass Modify giving details of the ny wel). The main) fuinetion need sony anspose of an array is obtained by interchang at a Ahan Transarray contains a two dimension aN Aije possible for both ‘m’ and ‘n’ is 20, Design a ca rear aa spiieiven matrix. The details of the members of maaeiree sans ees w class are given below ‘pata membersfinstant variables: arf I) Stores the matrix elements, Integer to store number of columns. ange oid AN ing the elements of r - Ale a ‘Member functions/methods: + Default constructor. Transarray() ronsarray(int mm, int nn): To initialize the size of the matrix, m=mm, n=nn To enter elements of the matrix. void fillarray() void transpose To find transpose of a given matrix. (lransarray A) ‘oid disparray() : Display the array in t Specify the class Transarray giving details of the Iranspose(Transarray) and void disparray(). You need not wie Il: A class SortWord has been defined with the following details: : SortWord the matrix form. constructors, void fillarray(), veil the main function, Class name Data members/instance variables: pt + Stores the word. en Stores the length of the word er functions/methods: per Word Default constructor : 1 vord in lower €28e: peal + To accept the word in id oa. 1 tr che word in alphabeial am of characters wing Bubble sort technique and display it User Defined ‘and Constructors Class asaiass FiboString to gency, Pee Sbon,, =. oct iscein, ie a piston variabeg, OF the en . ton bers ms BR: ; 10 store (ne BE string : ESS i tanetions/methoas mber of yt the previ wera) constr ey cae ane rictor to ree) #9 accept the magi X=" von erate) Catanete and pce frm ye M2 string. Ey eration) bona st “ Rec. iS fi got AT ta tS: The sun rte FOO Ml be ps NE a the ty Bi iy the class FibOString, giving dota th will be “mpeg the seperate). Define the main Pas the constructor, % cost gy f enable the task Yo create an gone YOid accep) : contains a two dime ind el the function : xalecames the last the second row hegyree nf shulfe the nae Maxims ‘jer of the cass are Bien belo the fist and so ony The: the fir mee Name : Shift he details of te bers/instance variables: pata mem! mat [Jl] Stores the array element {integer to store the number of roy : 2 ei + integer to store the nu ec. number of columns “a sain(int mm, int nn) ——_: parameterized constructor to in members m=mm and n=nn aoe ot void input ) + enters the elements of the array oid eyclic(Shift P) + enables the matrix of the object P to shift each "upwards in a eyclic manner and store the elont matrix in the current object. void display( ) displays the matrix elements Specify the class Shift giving details of the constructor(), void input( ), void cyclic (Shift). Define the main function to create an object and call the methods accordingly fo enable the task of shifting the array elements. {USC 2016) 42h Aclass consChange has been defined with the following, details: Class name : ConsChange Data Members/instance variables: : stores the word word 4 len + stores the length of the word _ Member functions/methods: - ConsChange( ) - default constructor 7 _Yeidreadivond ) : stores word = oid shiftcons( ) «chile al the consonants ofthe word att BERN ; ervels (eg Spoon becomes SPR) followed by the v‘ Void changeword{ +: changes the case of a C shifted word to uppercase SPNoo). 1 occurring consonants of the for eg. Spnoo becomes“eames BEN tn afar etter oF OLS sty, eye mverMbOrs OF the clay iohi Se ke Capital“ Sven Sins taefinstance variate. an 10 store « torent x tunstionsfmethods: queny m0 detaut a Bet euang wy eet CoM I RapAStNg 9): heck be ph Totten othe ty sasplay) aisplays the sen fala ne Words be, . esate es Cantal wing i aang) and Void digplay() scart tnetions accordingly to ty ‘Aitving with etine th able the phe 8 saclass Convert tofind anal the Tiday numberiso4 and theyre em aBivond DMarch @, aba *2020, then the sown of the members of the Rance rca me ane ‘y Convert rt) gmembers/Instance variables: integer to store th Ber to store the day mum integer to store the day enh" InteReE to ata BY OF te monday é integer to store the year ethods/Member function a : constructor to initial jalize the data me oa accept . ae en serg day. to-date converts the date number to ite oy ? particular year and stores the date ind eo Bak OE 8 gpaify the class Convert giving details of the constrctot eet ord day. to_date( ) and void display(). Define a mai erctort aatold. accept): ( d display( ). Define a main() funet wid call the function accordingly to enable the task ee ane s Bien belo be below t pata Ba intial values #5, Adass Mix has been defined to mix two words, character by character, the fl y characte, inthe following manner: The first character of the first word is followed by the first character of the second word and so on. If the words are of different length, the remaining characters of the word are put at the end. Example: If the First word is “JUMP” and the second word is "STROLL", then the required word will be “JSUTMRPOLL” ome of the members of the class are given below: Class name : Mix wrd + to store a word Jen the length of the word "Member function/methods: ix( ) void feedword( ) jd mix_word(Mix P.Mix Q) : to store ze the data embers with ult constructor to initial Tegal intial VOIUES oa cage ‘accept the word in ‘ure BR case fsa words of objec P and ane above a and stores the resultant wont in the cut ; n he id display( ) splays the word ify the class Mix giving te eal te 0 mix_word(MixyMix) and vole ON 0 0 and call the functions accor! + defaes =yg ener Absries( ) the cass Recursion «, 0) Pee sbseries( ) You ey myo. YOU Need Not rey, 2 BME Rincon, 2° toy, woney I into 4) (gus ReeFact defines @ recurs” fais of the €lA88 are given Keiyn® “Wnetion , apne Ww ss f + Reg pate members/instance variaire, Reckact n r syember functions/methods secFact() oid reacimum( ) int factorial(int) void factseries( ) Spealy the class RecFact givin, oid readnum(), int factorial(int) to create an object and call + integer as number n ti integer as number of terms of series. P + integer to store power of ‘x + integer to store factorial constructor to store appropriate values to data members. : to accept integer n (as number of terms) and x. : to find and return g raised to the power h u the Recursive Technique. + to find and return factorial of y using Technique. Y : to find and return sum of ab 3 recursive functions getpo y the class MySeries giving details of constructor and th nt h), int findFact (int y) and long findsum( ). ; for you. Do not write the main function. ct has been defined to find the “HF js used to find the LCM en below: aay 7? ig TU Ae el ealrember functinsmethode Constructor to init DeciOt with 0. Assigns nn to n. “ Caleutates the octal equivatens gy fot sity the recursive technige" isplays the decimal 1 voit show) deel oet() and displays aciOet, giving details of the constructor, voig H Oe 6 Sethe Saal fine a IND Fenton to any Vos ens? Sage taaonescon 10 he "i pra g he mem can piu isdvantages of ung ection, Fone ae Prog. TA eres fe equal 10 Bote pata Saw Example: 28 = 22+ 82-4 + 64 = 68 4 oa ibe 68 = 6 + 8 = 36 + 64 = 100 metho 1) 10-1 +04 02=14040=1 perfect Hence, 28 is a happy number: of facto Example: 12 = 12+ 2=144=5 int SUES Hence, 12 is not a happy number. g check) pesign a class Happy to check if a given number is a happy numbers, voi ambers of the class are given below: me of Class name Happy : Data members/instance variables: fy the A “4 Eee eter pe yoid. chet Member functions: accordingly iacsyb) + Constructor to assign 0 ton. 4: Design 2 os void getnum(int nn) 5 ig ae Parametric value to the ny some of the (n = nn). e Class nam« int sum_sq_digits(int x) + Retums the sum of the square of the digis of ‘Data memb number x, using the recursive technique. art{ } void ishappy() : Checks if the given number is a happy ny n by calling the function sum sq digit, Member £ displays an appropriate messages. } Binsearch( Specify the class Happy giving details of the constructor(), void getrumint) ins void fillar 5q_ digits(int) and void ishappy(). Also define a main() function to create an aj void sort and call the methods to check the happy number. Prog. 12: An emirp number is a number which is prime backwards and forwards. ¢: 3 int bins 31 are both prime numbers. Thus, 13 is an emirp number. Design a class Fnitp check if a given number is Emirp number or not. Some of the members o! the are given below: Define t Class name : Emirp and int Data members/instance variables: a n : stores the number rev : stores the reversed number f : stores the divisor Member functions: eep(nt an): : to assign n=nn, rev=0 and f-2 int asprime( int x) + checks if the number is prime using the technique and returns 1 if prime othere " we re ee resuh dass BMIP giving der . co he), Define the matty D Fa OF the “PPro, ste Emixp number, SP RHON tg OPStr icy, nN jggs Perfect to check os ° give < Ot Af sald to be perfect if 4,8" Humbe, tent ‘tie original number] MOF the facg ® 8 Ps a eget #23 (Where 1,2 ang g ae ‘ey wo pe members OF the class ary n° fa ’ Biven bel At oF 6 sae F Perfect ‘ oo wa persfinstance variables: y he wit ; © store “gwMember functions: Hore the umes vetnt A) Paramet of factors(int i) terized Member numer 4 Tetums the sun = excluding i oad eK + checks whe UM of the fa el tor a the cursive ta fF © re message sult With an ay xity the class Perfect giving details of the const srsi8 4 check( )- Define a main TuctOr ), in i ie te 6) 0 or on eS |, pwign a class BinSearch to search for a pa peel He class are given an es Gass name : Binsearch pata members/Instance variable: anf] : to store integer element 9 : integer to store the size of the array Member function /methods: sinsearch(int m ) : parameterized constructor to initialize n=nn void fllarray( ) + to enter elements in array void sort( ) + sorts the array element in ascending order using. any standard sorting technique searches for the value ‘v’ using binary search ‘and recursive technique and retums its lealion if found, otherwise returns a oan Define the class Binsearch giving details of constructor) voi lara ds and int bin_gearch (int intint). Define the main 0) function aie all functions accordingly to enable the task int bin_search(int Lint u, int v)the points in space is Siven by the formula:declared with following details: Class name : Student Data members/instance variables : rollno(integer) : To store roll number of the student idno(integer) : To store identification number of the Member functions/methods SSA aS ze Salary (AAatdL Moat hy Moat s) \ gz payable salary a Model the above situation by defining classes emp Mhstractors and functions where class salary ts main() fanction to create object of class salary and yy Pree Se the classes ae as Follows on erations. Th Calas oun Matext os Oe Data members/instance variables ett an Double subecripted Integer aa es as wu Double. subseripted tntegan alll "3 ae as rp) no mt i a atith. “ be (integers) As number of rows and g war bLIEL Member functions/methods Matrixi() + A constructor to initialize af sr. also,cthen data membesy ga To input values of m,n, r,¢, as void readLimit() and columns of al {1,61} [} void input_a() » To input the values in matrix af | |} mxn. void input_b() + To input the values in matrix b{ ] | } wid rxc Model void showmats() 2 To print matrix af } { ] and matrix bf ][ need 2 ‘Class name 2 Matrix2 _¢ Define Data members/instance variables : The d dit) double subscripted integer array of size Member functions/methods Matrix 2() : A constructor to initialize matrix cf ] [ ] wi void find product() : To find the product of matrix af | {], bl] store the resultant matrix in ¢f } [ ]. The: can be multiplied if n=r void showmatrix() : To print matrix c{ ] {| if multiplication is. otherwise output the message “matrix matrix b cannot be multiplied Model the above situation by defining classes matrixl and matrix? ind constructors and functions where class matrix2 is derived from class matrix need not write main() function. For allotting study streams to the students, two classes “student” and “res Constructor to initialize 0 to the data mé Constructor to assign nr to roll no. ane no. Class name + Result Student() Student(int nr, int ni)cl) 1) withgl (J, bt) )andl J. The mati cation is dong atrix a an nbors/inatance variably ya Me, gud (Hosting) a (foatinn) ro wor junctions/methods ier wi pe eoat My OA 2 Not oy ot cna) ft raverage() “ een) oid getsro4rn() void display( student nt on the by conditions given decide student on at conaitions goon al mark S and avers Fks (tot), = ste am allot is of average marks ac oe sett of average mara gs oe and store stream a ae llotted to the average marks a8 per the Average Marks | Average Marks | Stream 80 and above 0-7 below 60 Science Commerce | ‘To display the stream allotted, ) Model the above classes by clefining constructors and member methods. Main) funtion noe not be written. ‘a class Calculate and a derived class Hef to find the HCF of two Define ‘The details of both the classes are given below: : Calculate Class name Data members/instance variable: n,n Member functions/methods void accept) void display() Class name Data members/instance variables : h Member functions/methods void findhef() void show(), (a) Specify the base class giving (H) Using the concept of inherit functions yoid findhef() an Integers whose hef is to be determ ‘To accept integers nl, n2. + To display nl and n2 with suit : Hef ; + Integers to store hef, + To find and store hef of ml + To display h with suitable details of old ‘tance specify th .d void show()- Tia Ma sf den'two'points (1) and 0: 92) at I+ (y2-yl)? int on a 2D two class Point represents @ PO! to help in finding distance beeenClass name Data members/Instance variabtes xt, yl 32, y2 dis Member functions/methods Point) abstract void readPoint() abstract void FindDistance() void show) Class name Data members/Instance variables: mid, midy Member functions/methods: void readPoint() Void FindDistance() void FindMidPoint() void Show() (@) Specify the class Point giving details of constructor, fun. abstract void readPoint() and (® Using the concept of inheritance, specify details of the abstract class functions abstr: FindDistance(), void FindMid The class Distance is derived from Prog. 7: Define a class BasePro and a derived Class name Data members/Instance variables: nl, n2 Member functions/methods: void enter() void Show() Class name 5 Data members/Instance variables: result Member functions/methods: void prod() void disp() : (a) Specify the class BasePro giv show(). (®) Using concept of inhertance, function voidprod() and void Prog. 8: The slope of a straight line is calcul _ Y2-yl Ee 2=x » Understanding ISP Rarmnistar Cninna— vw The details of both the classes are given belo : BasePro + Float variables whose products tobe + To input the values of nland n2 + To display values of ni and n2. + Float variable to store product. + To calculate the product of ni and n? by + To display the values of m1, n2 and their specify the class DerivPro by giving det coordinates in double distance in double ty. YP® louble ye ae abttact type tung To display the values ora Distance 7 "ang Te store mid and midy coor bs oor nat To input values of xt, y the c To find the distance between py To find the distance between pon (62, y2) declared in the class pnts 4s calculated asi midx= (21 5 (yl y2)/2. v2 a To display values of dist, mick ang u ction void Sha abstract void FindDistance(), \ the class Dista act Void read? ‘oid Show(). it. 1x2 and ya gg lass Point, a, ox, i nd Ince by. cin) iPoint() and vi am the class Point class DerivPro to find the product of typ rw: DerivPro the concept of inheritance ‘ing details of the function void enter() disp(). The main function need not to be lated as:PE 2) 2re the. nor es a yay ane (94) are the Has te ies 1s same" seo oe Othe slope #8 =} then hey He in eas Sebo the classes are ag Pe" Penayee Pe coe ‘ mn Fete Satewtance variabtes on ern’ x3, ¥3, x4 yt ¢ inate functionsimethods, Be store the valu Rasa the valu in dou oy he vw m= no YH naa ™= TG To store the si 3 slope of bath the To show the Taree a To determine: whether thellee eal : é perpendicular. ae to Specify the elass Point giving details of constnctoy, - Sees x, function void Show) and (o Using the concept of inheritance, specity the dl 0 n , ass Slope by gil ofthe functions void findSlope(), void Display) nd void Gaeta Slope is derived from the class Point. be aa es are parallel or « Acass Personal contains employee details and another class Retire employee's Provident Fund and Gratuity. The details of the two below: Class name Instance variables/Data members: Name + Stores the employee's name. Pan + Stores the employee's PAN. basic_pay + Stores the employee's basic Personal acc_NO- Member methods/functions: : Fema + Parameterized constructor 12 data members: 2 voip ay() «To display the emp pane ; Retire Pace yatial mbers: ; bles/Data meme? iors the CmPION + tores the employes ®Prog. 10 A class Prog. Ul: A class Representative has been defined to store the name anv Specify the clase Rersonal lav) Using the concep and the men lisgslay). Th details. of the author and another class foo ff the beaks i Class name Author Data members/Instance variables authorne name Member functions/methods Author) Authorvint. string) Parameterised constructor to author number and ame void show() + To display the author’s details Class name Booklist Data membervinstance variables bookno + Long type variable to store the booy bookname : Stores the book name. 5 price + Float variable to store the price edition + Integer type variable to store the dian Member functions/methods —: Booklist(...) + Parameterized constructor 0 assien data members of both the classes void show() » To display all the details. siving details of the constructor and member function Specify the class Author show(). Using the concept of inheritance, specify the class Booklist giving details ( constructor and the member function void show(), Also define the main f create an object and call methods accordingly, to enable the task. void finda address representatives. Define a subclass Sales which defines the bill number, item number of items sold and the price of the item, The details of both classes are) below: oid Class name + Representative void Sam Data Members/instance variables: name + To store the names of representative om © To store his address. a (6) Usir address Member functions/methods; + Constructor to initialize data member Representative() void read(String n, String add) : To store the name and address void display() © Displays the names and the acess es E ‘Understanding ISC Computer Science-xilwae membe! Fa Hate ynctions/methods simi AME a double =“ wat cal void play oa nny the class Represe co) ha void display(). ) UeRRallQ, void Mss Representa a base class and a derived * meget ‘of both the classes are iss name oo embersfinstance variables ae functions/methods: wa accept) void display) lass name pata membersfinstance variables: be le Member functions/methods: void Swap() void find Hef() the edit dition Ssign Values Ses, void show() (@) Specify the class Base giving (b) Using concept of - functions void Swap\(), need not to be written. tig. diet the concept of inheritance dQ) and void The main() + To accept integers ni To display ni and n2 with, inheritance, specify void findLem( 5 xs Finstance variables PECITY the cass clsplay() The aaa ang det lunction and algoritng 3 der class to § 0 find the Biven below: ‘ae Base ails of method im need not be em Ind LCM of tive nism Integers wi "Bers whose hef and lem is to be determina and 12, see suitable messages. + Integers to store hef and lem. To interchange values of nl and n2 if nl < : To find and store hef of nl, n2 i To find hef make use of followi (i) Decide greater and sm two. (ii) Divide the greater number! if remainder is zero (0 be the hef, otherwise — (iii) Store divisor as 4 mainder as divisor then re i). : To find Jem of nt andr) which has already been Product of numbets ef + To display values of ni an suitable thee ‘ : along with suitable ieee functions void accept the class Derive 8 () and void show( Jem =Member function Btowek Coo) Parnnvetwr Hata MeHers: tt ey a ] vost apsayo 40 dinplay th stuck ota ‘~ ] an riiemenes Vartsbivn i toon netionn/ methods p he ned COnatedictor to, NbOEK OF Hoth ch 10 update stork by adding with the vost update () ofthe rate, Also update the curune (quantity * unit price) void displayo 10 display the “stock dotaih uupdation ‘ong Specify the class Stock, giving dotaily of th CONKERLCIOF) and void g concept of inheritance, specify the tsp Void update) and void dixplay( )). The main function 4 Written A super class Bank has been defined to store the details of th = i W details of the custo Subclass Account that enables tnaactions for the customer tt the bengal geome of both the classes are given below: ‘The to cont Class name : Bank the as Data members/instance variables : a cyline name «stores the name of the customer The det aceno stores the account number interfa Pp {stores the principal amount in decimals Data & Member functions/methods double Bank...) + parameterized constructor to assign val ue instance variables, doubl void display( ) displays the details of the customer oa Class name + Account os Data members/instance varilables : a a amt £ stores the transaction amount in decimals be Member functions/methods wa Account(.. * parameterized constructor to assign valuest aa instance variables of both cla De void deposit( ) # accepts the amount andl updates the pri y p= ptamt Me void withdraw( ) accepts the amount and updates the pr Cal P= p-amt If the withdrawal amount is more than the Principal amount, then display the do “Insufficient balance “, If the principal amount after withdrawal is less than @ penalty is imposed by using the formula p=p-(500- p)/10. Vo void display() : displays the details of the customer. ; Using the concept of inheritance, specify the base class Bank. In the deriv A Account, perform the task by giving details of the constructor(...) ,void be _ withdraw() and void display( ), 7 ‘Understanding ISC Comouter Seianco-vua 1A aEEee to Bind the Sum 9 fos tae ofthe members gy tales" eal re Gestetner ayer funetions/methods set wane mann weft © vit sp 60 thane Chass mame: dispiay Gissmemberfinstancevarighje, © Sin “im ‘ frenpe Femconstntioas 10 store the sup Patan, fee) members ot ginet) Satins th splays the dan ig the concept of inheritance, spec a es, perform the task by giving the days une Sih aisplay( 8 the detals ofthe ean Number In jnterface Data is defined ee ni ed With a data the volume of the implementing shape aod & Method yok i volume) ie retontain the radius of a geometrical per ies of th shape. Define’a sui ate as the properti we interface Data and the cla pac ou is as € and calculates he ee es the volume of Soylinder. he details of the members of the int. Interface name 2 Data ct and both the cases are gee Data member double pi + initialize pi = Member function /methods | double volume( ) Class name Base Data member/Instance variable rad : to store the radius in deci ‘Member functions/methods: oi : parameterized constructor to ini : display the radius with approp class name : CalVol Data member/Instance variable ht W« Of both th th ta n mbes en seri both + to store the height in decimal * parameterized constructor 0 of both the classes double volume( + calculate the volume of 45 re ) (pitradius? *heighd eee void show( ) » display the dala Ter ap J ‘volume of the cylin pase has been e interface Data and the class b ie that the inter! ae Reece vol giving ti of inheritance, spe double vol d void show(): anne ; ey acs i gin function and 1600: han, — Ai ~ fe MAIN fancy i the Node is give.” et lass Node ( int 1; Node link 1 Write an Algorithm ow ist The method declaration i, Wold FindNode( Noe str ine Answer the following (0 Waite the inorder traversal of the a (@) State the height of the tree, if the (Gi List the leaf nodes of the tree ARISE Circular Queue is a linear data structure in which operation ae primed (Fist In First Out) and the last position is connected to the back postion tombe a onl circle. Define a class CQueue with the following details nables Class name nina Data members / instance variables: array to hold the integer elements or aan Sey ae to point the index ofthe font to point the index of the rea. ructor to initialize the data member constructor 1 lie Os ea ogee theron (“Full from rear”) front = reat to add an in-2 «
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6125)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (932)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8214)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2922)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2530)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel