Posts

Showing posts with the label semester 2

Stack Program ISC Computer Science 2022 Semester 2 Theory

A 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 end only. The details of the class Stack is given below: Class name : Stack Data members/instance variables : cha[]: array to hold the characters size: stores the maximum capacity of the stack top: to point the index of the topmost element of the stack Member functions/methods : Stack(int m): constructor to initialize the data member size = m, top = -1 and create the character array void pushChar(char v): to add characters from the top end if possible else display the message "Stack full" char popChar(): to remove and return characters from the top end, if any, else returns '$' void display(): to display elements of the stack Specify the class Stack, giving details of void pushChar(char) and char popChar(). Assume that the other functions have ben defined. The main() function and algorithm need not be written. import java.util.Scanner...

Item Inheritance ISC Computer Science 2022 Semester 2 Theory

A super class Item has been defined to store the details of an item sold by a wholesaler to a retailer. Define a subclass Taxable to compute the total amount paid by the retailer along with service tax. Some of the members of both the classes are given below: Class name : Item Data members/instance variables : name: to store the name of the item code: integer to store the item code amount: stores the total sale amount of the item (in decimals) Member functions/methods : Item(...): parameterized constructor to assign values to the data members void show(): to display the item details Class name : Taxable Data members/instance variables : tax: to store the service tax (in decimals) totamt: to store the total amount (in decimals) Member functions/methods : Taxable(...): parameterized constructor to assign values to the data members of both the classes void calTax(): calculates the service tax @ 10.2% of the total sale amount. Calculates the total amount paid by the retailer as (total sa...

Reverse Number ISC Computer Science 2022 Semester 2 Theory

Design a class Revno which reverses an integer number. Example : 94765 becomes 56749 on reversing the digits of the number. Some of the members of the class are given below: Class name : Revno Data members/instance variables : num: to store the integer number Member functions/methods : Revno(): default constructor void inputNum(): to accept the number int reverse(int n): returns the reverse of a number by using recursive technique void display(): displays the original number along with its reverse by invoking the method reverse() Specify the class Revno, giving details of the constructor, void inputNum(), int reverse(int) and void display(). Define the main() function to create an object and call the functions accordingly to enable the task. import java.util.Scanner; class Revno{     int num;     public Revno(){         num = 0;     }     public void inputNum(){         Scanner in = new Scanner(System.in)...

Calculate Series ISC Computer Science 2022 Semester 2 Theory

A class CalSeries has been defined to calculate the sum of the series: sum = 1 + x + x 2 + x 3 + ... + x n Some of the members of the class are given below: Class name : CalSeries Data members/instance variables : x: integer to store the value of x n: integer to store the value of n sum: integer to store the sum of the series Methods/Member functions : CalSeries(): default constructor void input(): to accept the values of x and n int power(int p, int q): return the power of p raised to q (p q ) using recursive technique void cal(): calculates the sum of the series by invoking the method power() and displays the result with an appropriate message Specify the class CalSeries, giving details of the constructor, void input(), int power(int, int) and void cal(). Define the main() function to create an object and call the member functions accordingly to enable the task. import java.util.Scanner; class CalSeries{     int x;     int n;     int sum;   ...

No Repeat Program ISC Computer Science 2022 Semester 2 Theory

Design a class NoRepeat which checks whether a word has no repeated alphabets in it. Example : COMPUTER has no repeated alphabets but SCIENCE has repeated alphabets. The details of the class are given below: Class name : NoRepeat Data members/instance variables : word: to store the word len: to store the length of the word Methods/Member functions : NoRepeat(String wd): parameterized constructor to initialize word = wd boolean check(): checks whether a word has no repeated alphabets and returns true else returns false void prn(): displays the word along with an appropriate message Specify the class NoRepeat, giving details of the constructor, boolean check() and void prn(). Define the main() function to create an object and call the functions accordingly to enable the task. import java.util.Scanner; class NoRepeat{     String word;     int len;     public NoRepeat(String wd){         word = wd;         len = word.le...

Unique Word ISC Computer Science 2022 Semester 2 Theory

Design a class Unique , which checks whether a word begins and ends with a vowel. Example : APPLE, ARORA, etc. The details of the members of the class are given below: Class name : Unique Data members/instance variables : word: stores the word len: to store the length of the word Methods/Member functions : Unique(): default constructor void acceptWord():  to accept the word in uppercase boolean checkUnique() checks and returns 'true' if the word starts and ends with a vowel otherwise returns 'false' void display(): displays the word along with an appropriate message Specify the class Unique giving details of the constructor, void acceptWord(), boolean checkUnique() and void display(). Define the main() function to create an object and call the functions accordingly to enable the task. import java.util.Scanner; class Unique{     String word;     int len;     public void acceptWord(){         Scanner in = new Scanner(System.in); ...

ICSE Computer Applications 2022 Semester 2 Examination

SEMESTER 2 EXAMINATION COMPUTER APPLICATIONS Maximum Marks: 50 Time Allowed: One and a half hours Answers to this paper must be written on the paper provided separately. You will not be allowed to write during the first 10 minutes. This time is to be spent in reading the question paper. The time given at the head of this paper is the time allowed for writing the answers. Attempt all questions from Section A and any four questions from Section B. The marks intended for questions are given in brackets [ ]. SECTION A (Attempt all questions) Question 1 [10] Choose the correct answers to the questions from the given options. (Do not copy the question. Write the correct answer only) (i) Return data type of isLetter(char) is ________. (a) Boolean (b) boolean (c) bool (d) char (ii) Method that converts a character to uppercase is ________. (a) toUpper() (b) ToUpperCase() (c) toUppercase() (d) toUpperCase(char) (iii) Give the output of the following String methods: "SUCESS".indexOf(...