Posts

Showing posts from July, 2022

Matrix Transpose ISC Computer Science 2009 Theory

A transpose of an array is obtained by interchanging the elements of the rows and columns. A class Transarray contains a two-dimensional integer array of order (m × n). The maximum value possible for both 'm' and 'n' is 20. Design a class Transarray to find the transpose of a given matrix. The details of the members of the class are given below: Class name : Transarray Data members/instance variables : arr[][]: stores the matrix elements m: integer to store the number of rows n: integer to store the number of columns Member functions : Transarray(): default constructor Transarray(int row, int col): to initialize the size of the matrix as m = row, n = col void fillArray(): to enter the elements of the matrix void transpose(Transarray a): to find the transpose of a given matrix void dispArray(): displays the array in a matrix form Specify the class Transarray giving details of the constructors, void fillArray(), void transpose(Transarray) and void dispArray(). You need

Remove Duplicate Elements from an Integer Array in Java

Write a program in Java to remove all the duplicate elements in a one-dimensional array. The details of the class, its variables and member functions are given below: Class name : Remove Data members/instance variables : a[]: integer array to store the elements n: to store the size of the array Methods : Remove(int m): parameterized constructor to store n = m void input(): to enter the elements in the array void duplicate(): to remove all the duplicate elements from the array void display(): to display the final array Also write the main() method to create an object of the class and call the methods accordingly to enable the task. import java.util.Scanner; class Remove{     int a[];     int n;     public Remove(int m){         n = m;         a = new int[n];     }     public void input(){         Scanner in = new Scanner(System.in);         System.out.println("Enter " + n + " elements:");         for(int i = 0; i < a.length; i++)             a[i] = Integer.parseI

Date Validity Program ISC Computer Science 2011 Practical

Design a program which accepts your date of birth in dd mm yyyy format. Check whether the date entered is valid or not. If it is valid, display "VALID DATE" and also compute and display the day number of the year for the date of birth. If it is invalid, display "INVALID DATE" and then terminate the program. Test your program for the given sample data and some random data. Example 1 : INPUT: Enter your date of birth in dd mm yyyy format: 05 01 2010 OUTPUT: VALID DATE DAY NUMBER: 5 Example 2 : INPUT: Enter your date of birth in dd mm yyyy format: 03 04 2010 OUTPUT: VALID DATE DAY NUMBER: 93 Example 3 : INPUT: Enter your date of birth in dd mm yyyy format: 34 06 2010 OUTPUT: INVALID DATE import java.util.Scanner; class MyDate{     public static void main(String[] args){         Scanner in = new Scanner(System.in);         System.out.println("Enter your date of birth in dd mm yyyy format: ");         int dt = Integer.parseInt(in.nextLine());         int mt = I

Encryption Program ISC Computer Science 2011 Practical

Encryption is a technique of coding messages to maintain their secrecy. A string array of size 'n' where 'n' is greater than 1 and less than 10, stores single sentences (each sentence ends with a full stop) in each row of the array. Write a program to accept the size of the array. Display an appropriate message if the size is not satisfying the given condition. Define a string array of the inputted size and fill it with sentences row-wise. Change the sentence of the odd rows with an encryption of two characters ahead of the original character. Also change the sentence of the even rows by storing the sentence in reverse order. Display the encrypted sentences as per the sample data given below: Test your program on the sample data and some random data. Example 1 : INPUT: n = 4 IT IS CLOUDY. IT MAY RAIN. THE WEATHER IS FINE. IT IS COOL. OUTPUT: KV KU ENQWFA. RAIN MAY IT. VJG TGCVJGT KU HKPG. COOL IS IT. Example 2 : INPUT: n = 13 OUTPUT: INVALID ENTRY import java.util.Scan

Display Number in Words ISC Computer Science 2011 Practical

Write a program to input a natural number less than 1000 and display it in words. Test your program for the given sample data and some random data. INPUT: 29 OUTPUT: TWENTY NINE INPUT: 17001 OUTPUT: OUT OF RANGE INPUT: 119 OUTPUT: ONE HUNDRED AND NINETEEN INPUT: 500 OUTPUT: FIVE HUNDRED import java.util.Scanner; class Words{     public static void main(String[] args){         Scanner in = new Scanner(System.in);         System.out.println("Enter natural number < 1000");         int num = Integer.parseInt(in.nextLine());         if(num >= 1000){             System.out.println("OUT OF RANGE");             return;         }         int hundreds = num / 100;         int tens = (num % 100);         int ones = (num % 100) % 10;         String w[] = {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "ELEVEN", &qu

Bank Inheritance Program ISC Specimen 2023 Theory

A super class Bank has been defined to store the details of the customer in a bank. Define a subclass Interest to calculate the compound interest. The details of the members of both the classes are given below: Class name : Bank Data members/instance variables : name: to store the name of the customer accNo: integer to store the account number principal: to store the principal amount in decimals Methods/member functions : Bank(...): parameterized constructor to assign values to the data members void display(): to display the customer details Class name : Interest Data members/instance variables : rate: to store the interest rate in decimals time: to store the time period in decimals Methods/member functions : Interest(...): parameterized constructor to assign values to the data members of both the classes double calculate(): to calculate and return the compound interest using the formula: CI = P(1 + R / 100) N - P, where P is the principal, R is the rate and N is the time void displ

Holder Queue ISC Specimen 2023 Theory

Holder is a kind of data structure which can store elements with the restriction that an element can be added from the rear end and removed from the front end only. Class name : Holder Data members/instance variables : q[]: array to hold integers cap: maximum capacity of the holder front: to point the index of the front end rear: to point the index of the rear end Methods/Member functions : Holder(int n): constructor to initialize cap = n, front = 0 and rear = 0 void addInt(int v): to add integers in the holder at the rear end if possible, otherwise display the message "HOLDER IS FULL" int removeInt(): removes and returns the integers from the front end of the holder if any, else returns -999 void show(): displays the elements of the holder (i) Specify the class Holder giving details of the function void addInt(int) and int removeInt(). Assume that the other functions have been defined. import java.util.Scanner; class Holder{     int q[];     int cap;     int front;     int

Encrypt Program ISC Specimen 2023 Theory

A class Encrypt has been defined to replace only the vowels in a word by the next corresponding vowel and forms a new word, i.e. A → E, E  → I, I  → O, O  → U and U  → A. Example : Input: COMPUTER Output: CUMPATIR Some of the members of the class are given below: Class name : Encrypt Data members/instance variables : wrd: to store a word len: integer to store the length of the word newWrd: to store the encrypted word Methods/Member functions : Encrypt(): default constructor to initialize data members with legal initial values void acceptWord(): to accept a word in uppercase void freqVowCon(): finds the frequency of the vowels void nextVowel(): replaces only the vowels from the word stored in 'wrd' by the next corresponding vowel and assigns it to 'newWrd', with the remaining alphabets unchanged void disp(): displays the original word along with the encrypted word Specify the class Encrypt giving details of the constructor, void acceptWord(), void freqVowCon(), void nex

Odd Even ISC Specimen 2023 Theory

Design a class OddEven to arrange two single dimensional arrays into one single dimensional array, such that the odd numbers from both the arrays are at the beginning followed by the even numbers. Example : Array 1: {2, 13, 6, 19, 26, 11, 4} Array 2: {7, 22, 4, 17, 12, 45} Arranged Array = {13, 19, 11, 7, 17, 45, 2, 6, 26, 4, 22, 4, 12} Some of the members of the class are given below: Class name : OddEven Data members/instance variables : a[]: to store integers in the array m: integer to store the size of the array Methods/Member functions : OddEven(int num): parameterized constructor to initialize the data member m = num void fillArray(): to enter integer elements in the array OddEven arrange(OddEven p, OddEven q): stores the odd numbers from both the parameterized object arrays followed by the even numbers from both the arrays and returns the object with the arranged array void display(): displays the elements of the arranged array Specify the class OddEven giving details of the co

Pronic Number ISC Specimen 2023 Theory

Design a class Pronic to check if a given number is a pronic number or not. A number is said to be pronic if the product of two consecutive numbers is equal to the number. Example : 0 = 0 × 1 2 = 1  × 2 6 = 2  × 3 12 = 3  × 4 Thus, 0, 2, 6, 12 are pronic numbers. Some of the members of the class are given below: Class name : Pronic Data members/instance variables : num: to store a positive integer number Methods/Member functions : Pronic(): default constructor to initialize the data member with legal initial value void acceptNum(): to accept a positive integer number boolean isPronic(int v): returns true if the number 'num' is a pronic number, otherwise returns false using recursive technique void check(): checks whether the given number is a pronic number by invoking the function isPronic() and displays the result with an appropriate message Specify the class Pronic giving details of the constructor, void acceptNum(), boolean isPronic() and void check(). Define a main() funct

Dudeney Number in Java

What is a Dudeney Number? A dudeney number is a positive integer such that it's cube root equals its sum of digits. Some examples of Dudeney Numbers Consider the number 512. Sum of digits = 5 + 1 + 2 = 8. Cube root of 512 = 8. So, 512 is a dudeney number. Consider another number 4913. Sum of digits = 4 + 9 + 1 + 3 = 17. Cube root of 4913 = 17. So, 4913 is also a dudeney number. Dudeney Number Program in Java import java.util.Scanner; class Dudeney{     public static void main(String args[]){         Scanner in = new Scanner(System.in);         System.out.print("Enter the number: ");         int num = Integer.parseInt(in.nextLine());         int sum = 0;         for(int i = num; i != 0; i /= 10)             sum += i % 10;         double c = Math.cbrt(num);         if(sum == c)             System.out.println(num + " is a dudeney number");         else             System.out.println(num + " is not a dudeney number");     } }

Class 5 Formatting in MS Word

A Fill in the blanks with the correct words. 1. Format Painter button is available in the Clipboard group of the HOME tab. 2. Any text below the line of normal text is called Subscript . 3. The Page Setup group on the PAGE LAYOUT tab is used for page formatting. 4. To display the rulers, click the VIEW tab. 5. The page orientation is said to be Portrait if the document is printed along the breadth of the paper. B Write T for the true and F for the false statements. 1. Superscript option is available on the Font group of INSERT tab. ( F ) 2. On the horizontal ruler, the shaded parts depict the left and right margins. ( T ) 3. You can print a document along the length or the breadth of the page. ( T ) 4. If the document is printed along the length of the paper, the page orientation is said to be Portrait. ( F ) 5. Header is printed at the top of only first two pages. ( F ) C Choose the correct option. 1. ________ allows you to copy all the formatting. a. Copy b. Copy All c. Format Pa

Stack of Names ISC Computer Science 2011 Theory

Stack is a kind of data structure which can store elements with the restriction that an element can be added or removed from the top only. The details of the class Stack is given below: Class name : Stack Data members/instance variables : st[]: the array to hold the names size: the maximum capacity of the string array top: the index of the topmost element of the stack ctr: to count the number of elements of the stack Member functions : Stack(): default constructor Stack(int cap): constructor to initialize size = cap and top = -1 void pushName(String n): to push a name into the stack. If the stack is full, display the message "OVERFLOW" String popName(): removes a name from the top of the stack and returns it. If the stack is empty, display the message "UNDERFLOW" void display(): display the elements of the stack (a) Specify the class Stack giving details of the constructors, void pushName(String n), String popName() and void display(). The main() function and algor

Record Inheritance ISC Computer Science 2011 Theory

A super class Record has been defined to store the names and ranks of 50 students. Define a sub-class Rank to find the highest rank along with the name. The details of both classes are given below: Class name : Record Data members/instance variables : name[]: to store the names of students rnk[]: to store the ranks of students Member functions : Record(): constructor to initialize data members void readValues(): to store the names and ranks void display(): displays the names and the corresponding ranks Class name : Rank Data members/instance variables : index: integer to store the index of the topmost rank Member functions : Rank(): constructor to invoke the base class constructor and to initialize index = 0 void highest(): finds the index/location of the topmost rank and stores it in index without sorting the array. void display(): displays the names and ranks along with the name having the topmost rank. Specify the class Record giving details of the constructor, void readValues() a

Pseudo Arithmetic ISC Computer Science 2011 Theory

You are given a sequence of N integers, which are called as pseudo arithmetic sequences (sequences that are in arithmetic progression). Sequence of N integers: 2, 5, 6, 8, 9, 12 We observe that 2 + 12 = 5 + 9 = 6 + 8 = 14. The sum of the above sequence can be calculated as 14 × 3 = 42. For sequence containing an odd number of elements, the rule is to double the middle element. For example: 2, 5, 7, 9, 12 = 2 + 12 = 5 + 9 = 7 + 7 = 14. 14  × 3 = 42 (middle element = 7) A class Pseudoarithmetic determines whether a given sequence is a pseudo-arithmetic sequence. The details of the class are given below: Class name : Pseudoarithmetic Data members/instance variables : n: to store the size of the sequence a[]: integer array to store the sequence of numbers flag: store the status sum: store the sum of sequence of numbers r: store the sum of the two numbers Member functions : Pseudoarithmetic(): default constructor void accept(int num): to assign num to n and to create an integer array. Fill