Computer ScienceCOMPLETE ICSE
Computer ScienceCOMPLETE ICSE
CISCE
Academic Year: 2023-2024
(English Medium)
Date & Time: 13th March 2024, 11:00 am
Q1. Choose the correct answers to the questions from the given options. (Do not copy
the questions, write the correct answer only.)
1.1. Consider the above picture and choose the correct statement from the following:
Solution
Explanation:
The class is a polygon, and its types include triangle, parallelogram, and pentagon. As
a result, they fall under the Polygon class.
1.2. int x = 98; char ch = (char)x; what is the value in ch?
1. b
2. A
3. B
4. 97
Solution
Explanation:
'A' has an ASCII value of 97; hence, ' B' has an ASCII value of 98.
1. 9
2. 7
3. 6
4. (-1)
Solution
Explanation:
1. Package
2. Public
3. Protected
4. Private
Solution
Explanation:
The private access specifier restricts access to the class solely, providing the least
amount of accessibility.
1. 11
2. -11
3. 0
4. 13
Solution
Explanation:
1. /n
2. \t
3. /t
4. //n
Solution
\t
Explanation:
1. b
2. c
3. a
4. Wrong expression
Solution
If (a>b&&b>c) then largest number is a.
Explanation:
1. 10.0
2. 11.0
3. 12.0
4. 9.0
Solution
11.0
Explanation:
1. isDigif(char)
2. isLetterOrDigit()
3. isLetterOrDigit(char)
4. isLETTERorDIGIT(char)
Solution
isLetterOrDigit(char)
Explanation:
1. exe
2. obj
3. jvm
4. java
Solution
Explanation:
1.11. The number of bytes occupied by a character array of four rows and three
columns is ______.
1. 12
2. 24
3. 96
4. 48
Solution
The number of bytes occupied by a character array of four rows and three columns
is 24.
Explanation:
• Thus, 2 * 4 * 3 = 24.
1.12. Which of the following data type cannot be used with switch case construct?
1. int
2. char
3. String
4. Double
Solution
Double
Explanation:
1. for 2. while
3. do..while 4. switch
1. Only 1
2. 1 and 2
3. 1 and 3
4. 3 and 4
Solution
1 and 2
Explanation:
The for loop and while loop are entry-controlled loops that check the condition before
entering the loop body.
1. Impure method
2. Pure method
3. Constructor
4. Destructor
Solution
Explanation:
The procedure of reversing a number generates a new number that is the reverse of
the original number but does not modify the original number.
1.15. If the name of the class is "Yellow", what can be the possible name for its
constructors?
1. yellow
2. YELLOW
3. Yell
4. Yellow
Solution
Yellow
Explanation:
The constructor will have the same name as the class itself.
1. Call by reference
2. Call by value
3. Call by method
4. Call by constructor
Solution
Explanation:
Passing an argument as an object acts as a call by reference since only one copy of
the object is shared by both the caller and the called method.
1.17. The correct statement to create an object named mango of class fruit:
Solution
Explanation:
The class and object names should be the same, as specified in the query.
1.18. Assertion (A): Static method can access static and instance variables.
Solution
Explanation:
The static method can only access itself, whereas an instance variable can be
accessed through a class object. Thus, we can conclude that static methods cannot
access instance variables without the assistance of an object.
In contrast, static variables can be immediately accessed by both static and instance
methods.
1. 6
2. 5
3. 3
4. 2
Solution
Explanation:
The array element at index position 2 i.e. color[2] is "Violet" and the number of
characters in "Violet" is 6.
1. Math.ceil(n)
2. Math.sqrt(n)
3. Math.floor(n)
4. Math.round(n)
Solution
Math.round(n)
Explanation:
This method rounds up/down a supplied decimal value to a whole number. For
example, Math.round(5.5) = 6, but Math.round(5.4) = 5.
Q2.
Solution
Solution
2.4. Give the output of the following program segment. How many times is the loop
executed?
Solution
The for loop will run 0 times as the condition is false, and the loop is entry-controlled.
Solution
2.6. Consider the following two-dimensional array and answer the questions given
below:
Solution
Solution
2.8. The following code to compare two strings is compiled, the following syntax error
was displayed - incompatible types - int cannot be converted to boolean.
Identify the statement which has the error and write the correct statement. Give the
output of the program segment.
Solution
-4
Reason:
compareTo() gives the ASCII difference between the first two dissimilar characters
present in the string, but if any one of the strings ends early, then it returns the
difference of the length.
2.9. Consider the given program and answer the questions given below:
a. What concept of OOPs is depicted in the above program with two
constructors?
Solution
b. 10
30
2.10. Primitive data types are built in data types which are a part of the wrapper
classes. These wrapper classes are encapsulated in the java.lang package. Non
primitive datatypes like Scanner class are a part of the utility package for which an
object needs to be created.
a. To which package the Character and Boolean classes belong?
Solution
a. java.lang
b.
SECTION-B (60 Marks) (Answer any four questions from this Section.)
‘The answers in this section should consist of the programs in either BlueJ
environment or any program environment with Java as the base.
Q3. DTDC, a courier company, charges for the courier based on the weight of the
parcel. Define a class with the following specifications:
Member methods:
void accept ( )- to accept the details using the methods of the Scanner class
only.
void main ()- to create an object of the class and invoke the methods
Solution
Output:
double perform (double r, to calculate and return the value of Curved surface
double h) area of cone CSA π rl
void perform (int r, int c) Use NESTED FOR LOOP to generate the following
format r = 4, c = 5 output -
12345
12345
12345
12345
void perform (int m, int n, to print the quotient of the division of m and n if ch is Q
char ch) else print the remainder of the division of m and n if ch
is R
Solution
Output:
12345
12345
12345
12345
12345
Q5. Define a class to accept a number from user and check if it is an EvenPal number
or not. (The number is said to be EvenPal number when number is palindrome
number (a number is palindrome if it is equal to its reverse) and sum of its digits is an
even number.)
Solution
Output:
Q6. Define a class to accept values into an integer array of order 4 x 4 and check
whether it is a DIAGONAL array or not An array is DIAGONAL if the sum of the left
diagonal elements equals the sum of the right diagonal elements. Print the
appropriate message.
Example:
2 5 2 3 3 + 5 + 2 + 1 = 11
1 3 7 1 5 + 2 + 3 + 1 = 11
Solution
Output:
3425
2523
5327
1371
It is a DIAGONAL array
Q7. Define a class pin code and store the given pin codes in a single-dimensional
array. Sort these pin codes in ascending order using the Selection Sort technique
only. Display the sorted array.
Solution
Output:
Q8. Define a class to accept the gmail id and check for its validity.
A gmail id is valid only if it has:
→@
→ . (dot)
→ gmail
→ com
Solution
Output:
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 three questions from Section- B.
Section A
Question 1.
Choose the correct answers to the questions from the given options. (Do not copy the question. Write the correct answer only.) [10]
(a) toUpper()
(b) ToUpperCase()
(c) toUppercase()
(d) toUpperCase(char)
(a) 0 (b) 5
(c) 6 (d) -5
(v) …....class is used to convert a primitive data type to its corresponding object.
(vii) A single dimensional array contains N elements. What will be the last subscript?
(a) N (b) N-1
double C = Double.parseDouble(A);
double D = Double.parseDouble(B);
System.out.println((C+D));
Section-B
Question 2.
Define a class to perform binary search on a list of integers given below, to search for an element input by the user, if it is found display
the element along with is position, otherwise display the message “Search element not found”. [10]
Question 3.
Define a class to declare a character array of size ten. accept the characters into the array and display the characters with highest and
lowest ASCII (American Standard Code for Information Interchange) value. [10]
EXAMPLE :
INPUT:
‘R’, ‘z’, ‘q’, ‘A’, ‘N’, ‘p’, ‘m’, ‘U’, ‘Q’, ‘F’
OUTPUT :
Question 4.
Define a class to declare an array of size twenty of double datatype, accept the elements into the array and perform the following : [10]
Question 5.
Define a class to accept a string, and print the characters with the uppercase and lowercase reversed, but all the other characters should
remain the same as before. [10]
EXAMPLE: INPUT : WelCoMe_2022
OUTPUT : wELcOmE_2022
Question 6.
Define a class to declare an array to accept and store ten words. Display only those words which begin with the letter ‘A’ or ‘a’ and also
end with the letter ‘A’ or ‘a’.
EXAMPLE :
Input : Hari, Anita, Akash, Amrita, Alina, Devi Rishab, John, Farha, AMITHA
Output: Anita
Amrita
Alina
AMITHA
Question 7.
Define a class to accept two strings of same length and form a new word in such a way that, the first character of the first word is followed
by the first character of the second word and so on. [10]
OUTPUT : BWAOLRLD
COMPUTER APPLICATIONS
(Theory)
(Two Hours)
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 intended marks for questions or parts of questions are given in brackets [ ].
Question 1.
(a) Define Java byte code. [2]
(ii) The method which terminates the entire program from any stage.
(i) double
(ii) String
(iii) char
(iv) Integer
(e) What is an operator? Name any two types of operators used in Java. [2]
Question 2.
(a) What is autoboxing in Java? Give an example. [2]
(b) State the difference between length and length() in Java. [2]
Question 3.
(a) Write a Java expression for the following: [2]
√𝑏 2 − 4𝑎𝑐
x+=x++ + x + ++y
System.out.println( s1.endsWith(''L'') );
(e) Give the output of the following program segment and mention how many times [2]
the loop will execute:
int k;
for ( k = 5 ; k < = 20 ; k + = 7 )
if ( k% 6==0 )
continue;
System.out.println ( k );
(f) What is the data type returned by the following library methods? [2]
(i) isWhitespace()
(ii) compareToIgnoreCase()
(g) Rewrite the following program segment using logical operators: [2]
if ( x > 5 )
if ( x > y )
System.out.println (x+y);
(h) Convert the following if else if construct into switch case: [2]
System.out . print(''COMPUTER'');
System.out . print(''HINDI'');
else
if(n1>n2)
r = true;
else
r = false;
SECTION B (60 Marks)
Attempt any four questions from this Section.
The answers in this Section should consist of the Programs in either Blue J environment or any
program environment with Java as the base.
Each program should be written using Variable descriptions/Mnemonic Codes so that the logic
of the program is clearly depicted.
Flow-Charts and Algorithms are not required.
Question 4.
A private Cab service company provides service within the city at the following rates: [15]
Member methods :
members to 0.0.
void calculate () - To calculate the bill as per the rules given above.
CAR TYPE:
KILOMETER TRAVELLED:
TOTAL BILL:
Create an object of the class in the main method and invoke the member methods.
Question 5.
Write a program to search for an integer value input by the user in the sorted list given [15]
below using binary search technique. If found display ''Search Successful'' and print
the element, otherwise display ''Search Unsuccessful''
Question 6.
Write a program to input a sentence and convert it into uppercase and display each [15]
word in a separate line.
Output : INDIA
IS
MY
COUNTRY
Question 7.
Design a class to overload a method Number( ) as follows: [15]
(i) void Number (int num , int d) - To count and display the frequency of a
digit in a number.
Example:
num = 2565685
d=5
Frequency of digit 5 = 3
(ii) void Number (int n1) - To find and display the sum of even digits of
a number.
Example:
n1 = 29865
Write a main method to create an object and invoke the above methods.
Question 8.
Write a menu driven program to perform the following operations as per user’s choice: [15]
(i) To print the value of c=a2+2ab, where a varies from 1.0 to 20.0 with increment
of 2.0 and b=3.0 is a constant.
A
AB
ABC
ABCD
ABCDE
Question 9.
Write a program to input and store integer elements in a double dimensional array of [15]
size 3 x 3 and find the sum of elements in the left diagonal.
Example:
1 3 5
4 6 8
9 2 4
General Instructions :
Question 1.
(a) Name any two basic principles of Object-oriented Programming.
(b) Write a difference between unary and binary operator.
(c) Name the keyword which :
(i) indicates that a method has no return type.
(ii) makes the variable as a class variable.
(d) Write the memory capacity (storage size) of short and float data type in bytes.
(e) Identify and name the following tokens :
(i) public
(ii) ‘a’
(iii) ==
(iv) {}
Solution.
(b)
Unary Operators Binary Operators
(i) The operators which act upon a (i) The operators which require two
single operand are called unary operands for their action are called
operators. binary operators.
(ii) They are pre-increment and post (ii) They are mathematical operators
increment (+ +) and relational operators.
(c)
(i) void
(ii) static
Question 2.
(a) Differentiate between if else if and switch-case statements. [2]
(b) Give the output of the following code : [2]
String P = “20”, Q = “19”,
int a = Integer .parselnt(P);
int b = Integer. valueOf(Q);
System.out.println(a+””+b);
(c) What are the various types of errors in Java ? [2]
(d) State the data type and value of res after the following is executed : [2]
char ch = ‘9’;
res = Character. isDigit(ch) ;
(e) What is the difference between the linear search and the binary search technique?
[2]
Solution.
(a)
if else if switch-case
(i) It evaluates integer, character, pointer or (i) It evaluates only character or integer
floating-point type or boolean type. value.
(ii) Which statement will be executed (ii) Which statement will be executed is
depend upon the output of the expression decided by user.
inside if statement.
(b) 2019
(c) Syntax error, Runtime error, Logical error
(d) boolean
True
(e)
Question 3.
(a) Write a Java expression for the following : [2]
|x2+2xy|
(b) Write the return data type of the following functions : [2]
(i) startsWith( )
(ii) random( )
(r) If the value of basic=1500, what will be the value of tax after the following statement
is executed? [2]
tax = basic > 1200 ? 200 : 100;
id) Give the output of following code and mention how many times the loop will execute
? [2]
int i;
for(i=5; i> =l;i~)
{
if(i%2 ==1)
continue;
System.out.print(i+ ”
}
(e) State a difference between call by value and call by reference. [2]
(f) Give the output of the following: [2]
Math.sqrt(Math.max(9, 16))
(g) Write the output for the following: [2]
String s1 = “phoenix”; String s2 =”island”;
System.out.prindn (s1.substring(0).concat (s2.substring(2)));
System.out.println(s2.toUpperCase( ));
(h) Evaluate the following expression if the value ofx=2,y=3 and z=1. [2]
v=x+–z+y+ + +y
(i) String x[ ] = {“Artificial intelligence”, “IOT”, “Machine learning”, “Big data”}; [2]
Give the output of the following statements:
(i) System.out.prindn(x[3]);
(ii) System.out.prindn(x.length);
(j) What is meant by a package? Give an example. [2]
Solution.
(e)
(f) 4.0
(g) phoenix land
ISLAND
(h) = 2 + 0 + 3 + 4
(i) (i) Big data
(ii) 4
(j) A package is an organized collection of classes which is included in the program as
per the requirement of the program. For example java.io package is included for input
and output operations in a program.
Question 4.
Design a class name ShowRoom with the following description :
Instance variables/ Data members :
String name – To store the name of the customer
long mobno – To store the mobile number of the customer
double cost – To store the cost of the items purchased
double dis – To store the discount amount
double amount – To store the amount to be paid after discount
Member methods: –
ShowRoom() – default constructor to initialize data members
void input() – To input customer name, mobile number, cost
void calculate() – To calculate discount on the cost of purchased items, based on
following criteria
void display() – To display customer name, mobile number, amount to be paid after
discount
Write a main method to create an object of the class and call the above member
methods.
Solution.
import java.io.*;
import java.util.*;
class ShowRoom {
String name;
long mobno;
double cost;
double dis;
double amount;
ShowRoom( ) {
name = ” “;
mobno =0;
cost = 0;
dis = 0;
amount = 0;
}
void input( ) {
Scanner sc = new Scanner(System.in);
System.out.println(“EnterName:”);
name = sc.nextLine( );
System.out.println(“Enter Mobile number:”);
mobno = sc.nextLong( );
System.out.println(“Enter cost:”);
cost = sc.nextDouble( );
}
void calculate( ) {
if (cost <= 10000){
dis cost*5/100;
amount = cost – dis;
}
else
if (cost > 10000 && cost < = 20000){
dis = cost* 10/100;
amount cost – dis;
}
else
if (cost > 20000 && cost < = 35000){
dis = cost* 15/100;
amount = cost – dis;
}
else
if (cost > 35000){
dis = cost*20/100;
amount = cost – dis;
}
}
void display( ) {
System.out.println(“Name::” +name);
System.out.println(“Mobile No.::” +mobno);
System.out.println(“Amount::” +amount);
}
public static void main(String args( )) {
ShowRoom ob = new ShowRoom( );
ob.input( );
ob.calculate( );
ob.display( );
}
}
Question 5.
Using the switch-case statement, write a menu driven program to do the following : [15]
(a) To generate and print Letters from A to Z and their Unicode Letters Unicode
Solution.
import java.io.*;
import java.util.*;
class SwitchCase {
public static void main(String args[ ]) {
Scanner sc = new Scanner (System.in);
System.out.println(” 1. Enter 1 for Unicode:”);
System.out.prindn(” 2. Enter 2 for Pattern:”);
System.out.println(“Enter your choice:”);
int choice sc.nextlntO;
switch(choice){
case 1:
char ch;
System.out.println( “Letters \t Unicode”);
for (ch = ‘A’; ch < = ‘Z’; ch+ +) {
System.out.println(ch +”\t” + (int)ch);
}
break;
case 2:
int i, j;
for (i = 1; i < = 5; i+ +) {
for (j = 1; j < = i; j + +)
{
System.out.print(j + “”);.
}
System.out.printlnO;
}
break;
default:
System.out.println(“Wrong choice entered:”);
}
}
}
Question 6.
Write a program to input 15 integer elements in an array and sort them in ascending
order using the bubble sort technique. [15]
Solution.
import java.io.*;
import java.util’*;
class AscendingOrder {
public static void main(String args[]) {
int i, j, temp;
Scanner sc = new Scanner(System.in);
int arr[] = new int[15];
System.out.println(“Enter 15 integers:”);
for (i = 0; i < = 15; i+ +) {
arr[i] = sc.nextlntO;
for(i = 0; i < 14; i++){
for(j = 0; j < 14 -i; j + +){
if(arr[j] > arr[j + 1]){
temp = arr[j];
arr[j] = arr [j + 1];
arr[j + 1] = temp;
}
}
}
System.out.println(“Elements in ascending order are::”);
for (i = 0; i < 15; i+ +) {
System.out.println(arr[i]);
}
}
}
}
Question 7.
Design a class to overload a function series() as follows: [15]
(a) void series (int x, int n) – To display the sum of the series given below:
x1 + x2 + x3 + ……………. xn terms
(b) void series (int p) – To display the following series:
0, 7, 26, 63 p terms.
(c) void series () – To display the sum of the series given below:
Solution.
import java.io.*;
import java.util.*;
class OverloadSeries {
void series( int x, int n) {
int i; .
double a;
double sum = 0;
for (i = 1; i < = n; i++) {
a = Math.pow(x, i);
sum = sum + a;
}
System.out.prindn(“Sum::” +sum)r
}
void series(int p) {
int i;
for (i = 1; i < = p; i++) {
System.out.prindn((i * i * i) – 1 + ” “);
}
}
void series() {
double i;
double s = 0;
for (i =-2; i < = 10; i+ +) {
s = s + 1/i;
}
System.out.println(“Sum:” +s);
}
}
Question 8.
Write a program to input a sentence and convert it into uppercase and count and display
the total number of words starting with a letter ‘A’. [15]
Example:
Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY
ARE EVER CHANGING.
Sample Output : Total number of words starting with letter A’ = 4.
Solution.
import java.io.*;
import java.util.*;
class UpperCount {
public static void main(String args[ ]) {
int i, a;
Scanner sc = new Scanner(System.in);
String str, str1, str2;
System.out.prindn(“Enter sentence::”);
str = sc.nextLine();
strl = str.toUpperCaseO; ‘
str2 = “” + strl;
a = 0; ,
for (i = 0; i < = str2.1ength(); i+ +) {
if(str2.charAt(i) == ‘ ‘)
if(str2.charAt(i + 1) == ‘A’);
a+ +;
}
System.out.println(“Total number of words starting with letter ‘A’::” +a);
}
}
Question 9.
A tech number has even number of digits. If the number is split in two equal halves, then
the square of sum of these halves is equal to the number itself. Write a program to
generate and print all four digit tech numbers. [15]
Example :
Consider the number 3025
Square of sum of the halves of 3025 = (30+25)2
= (55)2
= 3025 is a tech number.
Solution.
import java.io.*;
import java.util.*;
class TechNumber {
public static void main(String args[ ]) {
int i, a, b, sum;
String n;
System.out.println(“Four Digits Tech Numbers are::”);
for(i = 1000; i < 1000; i+ +) {
n = i +””;
a = lnteger,parselnt(n.substring(0, 2));
b = Integer.parselnt(n.substring(2));
sum = (int)Math.pow((a + b), 2);
if (sum == i)
System.out.println(i);
}
}
}
ICSE Paper 2018
Computer Applications
General Instructions:
Question 1.
(a) Define abstraction.
(b) Differentiate between searching and sorting.
(c) Write a difference between the functions isUpperCase( ) and toUpperCase( ).
(d) How are private members of a class different from public members ?
(e) Classify the following as primitive or non-primitive data types :
(i) char
(ii) arrays
(iii) int
(iv) classes
Solution:
(a) Abstraction is a process of hiding the implementation details and showing only
functionality to the user.
(c) The isUpperCase( ) method is used to check whether the given character is in upper
case or not. It returns Boolean data type.
The toUpperCase( ) method is used to convert a character or string into upper case. It
returns char or String type. •
(d) Scope of the private members is within the class whereas scope of the public
members is global.
Question 2.
(a) (i) int res = ‘A’; [2]
What is the value of res ?
(ii) Name the package that contains wrapper classes.
(b) State the difference between while and do while loop. [2]
(r) System.out.print(“BEST”); |2]
System.out.println(“OF LUCK”);
Choose the correct option for the output of the above statements
(i) BEST OF LUCK
(ii) BEST
OF LUCK
(d) Write the prototype of a function check which takes an integer as an argument and
returns a character. [2]
(e) Write the return data type of the following function. [2]
(i) endsWith( )
(ii) log( )
Solution:
(a) (i) Value of res is 65.
(ii) Java.lang
(b)
Question 3.
(a) Write a Java expression for the following :
(b) What is the value of y after evaluating the expression given below ?
y + = + +y+y–l –y; when int y=8
(c) Give the output of the following : [2]
(i) Math.floor (- 4.7)
(ii) Math.ceil(3.4) + Math.pow(2,3)
(d) Write two characteristics of a constructor. [2]
(e) Write the output for the following : [2]
System.out.prindn(“Incredible” + “\n” + “world”);
(f) Convert the following if else if construct into switch case [2]
if (var= = 1)
System.out .println(“good”);
else if(var= =2)
System.out.prindn(“better”);
else if(var= =3)
System.out.prindn( “best”);
else
System.out.prindn(“invalid”);
Solution:
(a) Math.sqrt * (3 * x + Math.pow(x, 2)) / (a + b);
(b) 8 + (9 + 9 + 7) = 8 + 25 =33
(c) (0 – 5.0 (it) 12.0
(d) (i) Constructor has the same name as of class.
(ii) Constructor gets invoked when an object is created.
(e) Incredible
world
(f) switch ( ) {
case 1:
System.out .println( “good”);
break; .
case 2:
System.out .println( “better”);
break;
case 3:
System.out.println( “invalid”);
break;
}
(g) (i) ACHIAVAMANT
(ii) – 18
(h) false (at index 0, DELHI consists of 5 characters, at index 3, LUCKNOW consists of 7
characters. Therefore 5 > 7 is false)
JAI (at index 4, JAIPUR exists and extract its three characters)
(i) discount = bill > 100 ? bill * 10.0 /100 : bill * 5.0 /100;
(j) 20. Loop will be executed for 0 times.
Member methods
void accept ( ) — To take input for name, coach, mobile number and amount
void update ( ) — To update the amount as per the coach selected
First_ AC 700
Second_AC 500
Third _AC 250
sleeper None
void display( ) — To display all details of a customer such as name, coach, total amount
and mobile number.
Write a main method to create an object of the class and call the above member
methods.
Solution:
import java.io.*;
import java.util.Scanner; class RailwayTicket {
String name, coach;
long mobno;
int amt, totalamt;
void accept( ) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter Passenger’s Name: “);
name = sc.next( );
System.out.print(“Enter Mobile Number:”);
mobno = sc.nextlnt( );
Systein.out.print(“Enter Coach (FirstAC/SecondAC/ThirdAC/sleeper):”);
coach = sc.next( );
System.out.print(“Enter basic amount of ticket:”);
amt = sc.nexdnt( );
}
void update!) {
if (coach.equals(“First_AC”))
totalamt = amt + 700;
else
if (coach.equals(“Second_AC”))
totalamt = amt + 500; .
else
if (coach.equals!”Third_AC”))
totalamt = amt + 250;
else
totalamt = amt;
}
void display() {
System.out.println(“\n\n Name :” +name);
System.out.println(“Coach :” +coach);
System.out.prindn(”Total Amount:” +totalaint);
System.out.prindn(“Mobile No.:” +name);
}
public static void main (String args[ ]) throws IOException {
RailwayTicket t = new RailwayTicket!);
t.accept();
t.update();
t.display();
}
}
Question 5.
Write a program to input a number and check and print whether it is a Pronic number
[15] or not. (Pronic number is the number which is the product of two consecutive
integers)
Examples : 12 = 3 × 4 .
20 = 4 × 5
42 = 6 × 7
Solution:
import java.io.*;
import java.util. Scanner;
class Pronic]
public static void main(String argsQ) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter the number: “);
int n = sc.nextlnt();
int i = 0;
while(i * (i + 1) < n) {
i++;
}
if(i *(i + 1) = = n){
System.out.println(n + ” is a Pronic Number.”);
}
else {
System.out.prindn(n + ” is not a Pronic Number.”);
}
}
}
Question 6.
Write a program in Java to accept a string in lower case and change the first letter of
every word to upper case. Display the new string. [15]
Sample input: we are in cyber world
Sample output : We Are In Cyber World
Solution:
import java.io.*;
import java.util.Scanner;
class ChangeLetter {
public static void main(String args[ ]) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter String in lowercase:”);
String str 1 = sc.next( );
strl = “” +strl;
String str2 = ” “:
for (int i = 0; i<strl.length( ); i+ +) {
if(strl ,charAt(i) = = “) {
str2 = str2 + ” +Character. toUpperCase(strl.charAt(i+l));
i+ + ;
}.
else
str2= str2 + strl.charAt(i);
}
System.out.println(str2.trim( ));
}
}
Question 7.
Design a class to overload a function volume() as follows : [15]
(i) double volume (double R) — with radius (R) as an argument, returns the volume of
sphere using the formula.
V = 4/3 × 22/7 × R3
(ii) double volume (double H, double R) – with height(H) and radius(R) as the
arguments, returns the volume of a cylinder using the formula.
V = 22/7 × R2 × H
(iii) double volume (double L, double B, double H) – with length(L), breadth(B) and
Height(H) as the arguments, returns the volume of a cuboid using the formula.
Solution:
class ShapesVolume {
public static double volume (double R) {
double V = 4.0 / 3, * 22.0 / 7 * Math.pow(R, 3);
return V;
}
public static double volume(double H, double R) {
double V = 22.0 / 7 * R * R * H ;
return V;
}
public static double volume (double L, double B, double H) {
double V = L * B * H;
return V;
}
}
Question 8.
Write a menu driven program to display the pattern as per user’s choice. [15]
import java.io.*;
import java.util.Scanner;
class Pattern {
public static void main(String args[]) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.println(“::::MENU::::”)
System.out.println(” 1. To display ABCD Pattern”);
System.out.print(” 2. To display Word Pattern”);
System.out.print(“Enter your choice:”);
int ch= sc.nextlnt();
switch(ch) {
case 1:
for (char i = ‘E’; i > = ‘A’; i- -){
for(char j = ‘A’;j <=i;j + +){
System.out.print(j);
}
System.out.prindn( );
}
break;
case 2:
String S = “BLUE”;
for (int i = 0; i < S.length(); i+ +) {
for(int j = 0; j < =i; j + +) {
System.out.print(S.charAt(i));
}
System.out.println();
}
break;
default:
System.out.println(“Invalid Input”);
break;
}
}
}
Question 9.
Write a program to accept name and total marks of N number of students in two single
subscript array name[] and total marks[ ]. [15]
Calculate and print:
Solution:
import java.io.*;
import java. util. Scanner;
class NameMarks {
public static void main(String argsO) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter number of students:”);
int N = sc.nextlnt( );
String named = new String[N];
int totalmarksG = new int[N];
double deviation[ ] = new double[N];
double sum = 0;
for (int i = 0; i < N; i+ +) {
System.out.print(“Enter Name of the Student:”);
name[i] = sc.next( );
System.out.print(“Enter Marks:”);
totalmarks[i] = sc.nextlntO;
sum = sum + totalmarks [i];
}
double average = sum / N;
System.out.println(“The average of the total marks of ” +N+” number of students:”
+average);
for (int i = 0; i < N; i+ +) {
deviadon[i] = total marks (i] – average;
System.out.println(“Deviation of” + name[i] + “s marks with the average:” +deviation[i]);
}
}
}
ICSE Paper 2017
Computer Applications
General Instructions:
Question 1.
(a) What is inheritance ? [2]
(b) Name the operators listed below r [2]
(0 <
(it) + +
(iii) &&
(iv) ? :
(c) State the number of bytes occupied by char and int data types. [2]
(d) Write one difference between / and % operator. [2]
(e) String x[ ] = {“SAMSUNG”, “NOKIA”, “SONY”, “MICROMAX”, “BLACKBERRY”}; [2]
Give the output of the following statements :
(i) System.out.prindn(x[1]);
(ii) System.out.println(x[3].length{ )); ,
Answers:
(a) Inheritance in java is a mechanism in which one object acquires all the properties
and behaviors of parent object.
The idea behind inheritance in java is that you can create new classes that are built
upon existing classes. When you inherit from an existing class, you can reuse methods
‘and fields of parent class, and you can add new methods and fields also.
(b) (i) Comparison operator
(ii) Unary operator
(iii) Logical operator
(iv) Ternary operator
(c) The char data occupies two bytes whereas int data type occupies four bytes.
(d) The / operator is used for division whereas % operator is used to find the remainder.
(e) (i) NOKIA
(ii) 8
Question 2.
(a) Name the following : [2]
(i) A keyword used to call a package in the program.
(ii) Any one reference data type.
(b) What are the two ways of invoking functions? [2]
(c) State the data type and value of res after the following is executed: [2]
char ch = ‘t’;
res=Character. toUpperCase(ch);
(d) Give the output of the following program segment and also mention the number of
times
the loop is executed: [2]
int a,b;
for (a=6, b=4; a< =24; a=a + 6)
{
if (a%b= =0)
break;
}
System, out .println(a);
Answers:
(a) (i) import
(ii) Array
(b) By Value and By Reference
(c) int type and value is 84.
(d) Output is 12. Twice.
In the loop : for (a = 6, b=4; a< =24; a = a+6), the value of a will be
incrementing as 6, 24 and upon incrementing the value to 42, the loop will terminate.
Accordingly the loop has to execute two times.
But within the loop there is a condition : if(a%b = =0) break;
This means when remainder on dividing a by b comes out to be 0 (at 24/4 = 0), the
condition breaks and from the above it is clear that value of a is incremented from 6 to
24 when the loop executes second time.
(e) 75 F
Question 3.
(a) Write a Java expression for the following : [2]
ax5 + bx3 + c
(b) What is the value of xl if x=5 ? [2]
x1 = + +x – X+ + + –x
(c) Why is an object called an instance of a class ? [2]
(d) Convert following do-while loop into for loop. [2]
int i = 1;
int d = 5;
do {
d=d*2;
System.out.println(d);
i+ + ; } while (i< =5);
(e) Differentiate between constructor and function. [2]
(g) What are the values stored in variables r! and r2: [2]
(i) double r1=Math.abs(Math.min(-2.83,-5.83));
(ii) double r2=Math.sqrt(Math.floor(16.3));
(i) Analyze the given program segment and answer the following questions : [2]
for(int i=3;i< =4;i+ +) {
for(int j=2;j<i;j+ +) {
System.out.print(” “); }
System.out.println(“WIN”); }
(i) How many times does the inner loop execute ?
(ii) Write the output of the program segment.
(f) What is the difference between the Scanner class functions nextQ and nextLine()? [2]
Answers:
(a) a.Math.pow(x,5) + b.Math.pow(x,3) +c;
(b) 6
(c) An object is a software bundle of related state and behavior. A class is a blueprint or
prototype from which objects are created. An instance is a single and unique unit of a
class.
(e) Constructors must be named with the same name as the class name. They cannot
return anything, even void (the object itself is the implicit return).
Functions must be declared to return something, although it can be void.
(f) 0
Today i Holiday
(g) r1 = 5.83 .
r2 = 4.0
(h) Result 1 = 26100200
Result 2 = 126
(i) (i) Once
(ii) WIN
WIN
(j)next ( ) can read the input only till the space. It cannot read two words separated by
space.
Also, next( ) places the cursor in the same line after reading the input.
nextLine( ) reads input including space between the words (that is, it reads till the end of
line \n). Once the input is read, nextLine( ) positions the cursor in the next line.
Section – B (60 Marks)
Question 4.
Define a class ElectricBill with the following specifications : [15]
class : ElectricBill
Member methods :
void accept ( ) – to accept the name of the customer and number of units consumed
void calculate ( ) – to calculate the bill as per the following tariff :
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
Write a main method to create an object of the class and call the above member
methods.
Answer:
import java.io.*;
class ElectricBill {
String n;
int units;
double bill ;
void accept() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print(“Name of the customer = “);
n = reader.readLine( );
System.out.print( “Number of units consumed = “);
String un = reader. readLine( );
units=Integer .parselnt(un);
}
void calculate!) {
if(units < = 100)
bill = 2.00*units;
if(units< =300) bill = 3.00*units; if (units > 300)
bill = 5.00*units;
}
void print( ) {
System.out.println(“Naine of the customer:” +n);
System.out.println(“Number of units consumed:” +units);
System.out.println(“Bill amount:” + bill);
}
public static void main(String argsQ) throws IO
Exception { ElectricBill eb = new ElectricBill( );
eb. accept!);
eb.calculate();
}
}
Question 5.
Write a program to accept a number and check and display whether it is a spy number
or not. (A number is spy if the sum of its digits equals the product of its digits.) [15]
Answer:
class Spy {
public static void main(int n) {
int sum = 0;
int multiple = 1;
int a;
int p = n;
// a stores each digit extracted and p creates a backup of input.
while(n ! = 0) {
a = n % 10; ,
sum = sum + a;
multiple = multiple * a;
n = n/10;
}
System.out.println(“The sum of ” +p +” is ”+sum);
System.out.println(“The product of “+p +” is ” + multiple);
if(sum = = multiple) {
System.out.println(“Aha, ” + “It is a Spy Number Where Sum = Product”);
}
else {
System.out.println(” It is NOT a Spy Number Where Sum ft Product”);
}
}
}
Question 6.
Using switch statement, write a menu driven program for the following : [15]
(i) To find and display the sum of the series given below :
S = x1 -x2 + x2 – x4 + x5 – x20
(where x = 2)
Answer:
import java.io.*;
class SwitchStatement {
public static void main(String argsQ) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(reader);
System.out.println(“l-Sum of Series:”);
System.out.println(“2-Display Special Series:”);
System.out.println(“Enter your choice:”);
String n1 = input.readLine( );
int ch = Integer.parselnt(nl);
System.out.println(“Enter Number of Terms
String t = input.readLine();
int n = Integer.parselnt(t);
switch (ch) {
case 1:
int sign = -1;
double term = 0;
double sum = 0;
int x = 2;
System.out.println(“Value of x: ” +x);
System.out.println(“Number of terms: ” +n);
sum + = x; // First term added here,
for (int i = 2; i < = n; i+ +){
term = sign * Math.pow(x,i);
sum + = term;
sign *= -1;
}
System.out.println(“Sum of Series +sum);
break;
case 2 :
int num;
System.out.println(“Enter the number of terms: ”);
String tm = input.readLine(); .
num = Integer.parselnt(tm);
int s = 0, c;
for (c = 1; c < = num; c+ +){
s = s * 10 + 1;
System.out.print(s + ” “);
}
break;
}
}
}
Question 7.
Write a program to input integer elements into an array of size 20 and perform the
following operations: [15]
(i) Display largest number from the array.
(ii) Display smallest number’from the array.
(iii) Display sum of all the elements of the array.
Answer:
import java.util.Scanner;
class LargeSmallSum {
public static void main(String args[ ]) {
int n;
int max, min, sum = 0;
int i, j;
Scanner s = new Scanner(System.in);
System.out.print(“Enter no. of elements you want in array:”);
n = s.nextlnt();
int a[ ] = new int[n];
System.out.println(“Enter all the elements:”);
for (i = 0; i < n; i+ +) {
a[i] = s.nextlntO;
}
max = a[0];
min = a[0];
for(i = 0; i < n ; i + +) { if(a[i] > max) {
max = a[i];
}
if (a[i] < min) {
min = a[i];
}
}
System.out.println(“Maximum Number is:”+max);
System.out.println(“Smallest Number is:” +min);
for(i = 0; i < n; i+ +) {
sum = sum + a[i];
}
System.out.println(“Sum of the Numbers is:” +sum);
}
}
Question 8.
Design a class to overload a function check ( ) as follows : [15]
(i) void check (String str, char ch) – to find and print the frequency of a character in a
string.
Example : *
Input:
str = “success”
ch = ‘s’ .
Output:
number of s present is = 3
(ii) void check(String si) – to display only vowels from string si, after converting it to
lower case.
Example:
Input:
s1 = “computer”
Output:
oue
Answer:
class CharacterVowel {
public void checkering str, char ch) {
int c = 0, code,i,s;
str = str.toLowerCase( );
int len = str.length( );
for (code = 97; code < 122; code+ +) {
c = 0;
for (i = 0; i < len; i+ +) {
ch = str.charAt(i);
s = (int) ch;
if(s = = code)
c = c + 1;
}
ch = (char)code;
if(c ! = 0)
System.out.println(“Frequency of “+ch+ “is” +c);
}
}
public void check(String si) {
int i;
char ch=0, chr=0;
for(i=0;i<s1.length();i+ +) {
ch = s1.charAt(i);
if(Character.isUpperCase(ch))
chr = Character. toLo werCase(ch);
if((s1 .charAt(i)==’a’) 11 (s1 .charAt(i) = ‘u’) | j(s1 .charAt(i) = = ‘o’)| | (s1 .charAt(i)==’i’)
11 (s1 .charAt(i) = = ‘e’))
System.out.println(s1 .charAt(i));
}
}
}
Question 9.
Write a program to input forty words in an array. Arrange these words in descending
order of alphabets, using selection sort technique. Print the sorted array. [15]
Answer:
import java.util.Scanner;
class Descending {
public static void main(String args[ ]) {
int n;
String temp;
Scanner s = new Scanner(System.in);
System.out.print(“Enter number of words you want to enter:”);
n = s.nextlnt( );
String names[ ] = new String[n];
Scanner s1 = new Scanner(System.in);
System.out.println(“Enter all words:”);
for(int i = 0; i < n; i+ +) {
names[i] = s1.nextLine[( );
}
for (int i = 0; i < n; i+ +){
for (int j = i + 1; j < n;j++){
if (names[i].compareTo(namesG]) < 0) {
temp = names [i];
names[i] = namesG];
names[j] = temp;
}
}
}
System.out.print(“Words in Descending Order:”);
for (int i = 0;i<n-l;i++){
System.out.print(names[i] + “,”);
}
System.out.print(names[n – 1]);
}
}
ICSE Paper 2016
Computer Applications
(Two Hours)
Answers to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 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.
This paper is divided into two Sections.
Attempt all questions from Section A and any four questions from Section B.
The intended marks for questions or parts of questions are given in brackets [ ].
Question 1:
(a) Define Encapsulation. [2]
(b) What are keywords ? Give an example. [2]
(c) Name any two library packages. [2]
(d) Name the type of error ( syntax, runtime or logical error) in each case given
below: [2]
(i) Math.sqrt (36 – 45)
(ii) int a;b;c;
(e) If int x [ ] = { 4, 3,7, 8, 9,10}; what are the values of p and q ? [2]
(i) p = x.length
(ii) q = x[2] + x[5] * x[1]
Answer:
(a) Encapsulation: It is process of wrapping code and data together into a single unit
(called class).
(b) Keywords: Keywords are reserved words in Java, which have a special meaning in
the language.
Example: if, void, int etc.
(c) (i) java.io
(ii) java.util
Question 2:
(a) State the difference between == operator and equals ( ) method. [2]
(b) What are the types of casting shown by the following examples: [2]
(i) char c = (char) 120;
(ii) int x = ‘t’;
(c) Differentiate between formal parameter and actual parameter. [2]
(d) Write a function prototype of the following: [2]
A function PosChar which takes a string argument and a character argument and
returns an integer value.
(e) Name any two types of access specifiers. [2]
Answer:
(a)
It checks for equality of primitive type of It checks for equality of two string type of
values. values.
(c)
Question 3:
(a) Give the output of the following string functions: [2]
(i) “MISSISSIPPI”.indexOf(‘S’) + “MISSISSIPPF”.lastIndexOf(‘I’)
(ii) “CABLE”.compareTo(“CADET”)
(f) Convert the following while loop to the corresponding for loop: [2]
int m = 5, n = 10;
while (n>=1)
{
System.out.println(m*n);
n-;
}
(g) Write one difference between primitive data types and composite data types. [2]
(h) Analyze the given program segment and answer the following questions: [2]
(i) Write the output of the program segment.
(ii) How many times does the body of the loop gets executed ?
(j) Write the return type of the following library functions: [2]
(i) is Letter Or Digit(char)
(ii) replace(char, char)
Answer:
(a) (i) 2 + 10 = 12
(ii) -3
(e) String k;
k = x%2 == 0 ? “EVEN” : “ODD”;
System.out.print(k);
(g)
Question 4:
Define a class named Book Fair with the following description: [15]
Instance variables/Data members :
Price Discount
Less than or equal to Rs. 1000 2% of price
(iv) Void display () — To display the name and price of the book after discount. Write a
main method to create an object of the class and call the above member methods.
Answer:
Question 5:
Using the switch statement, write a menu driven program for the following: [15]
(i) To print the Floyd’s triangle [Given below]
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(ii) To display the following pattern:
I C
I C S
I C S E
Answer:
Question 6:
Special words are those words which starts and ends with the same letter. [15]
Examples:
EXISTENCE
COMIC
WINDOW
Palindrome words are those words which read the same from left to right and vice
versa
Examples:
MALAYALAM
MADAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words, but all special words are not palindromes. Write a
program to accept a word check and print whether the word is a palindrome or only
special word.
Answer:
Question 7:
Design n class to overload a function SumSeriesO as follows: [15]
(i) void SumSeries(int n, double x) – with one integer argument and one double
argument to find and display the sum of the series given below:
(ii) void SumSeries() – To find and display the sum of the following series:
s = 1 + (1 x 2) + (1 x 2 x 3) + ….. + (1 x 2 x 3 x 4 x 20)
Answer:
Question 8:
Write a program to accept a number and check and display whether it is a Niven number
or not. [15]
Example:
Consider the number 126.
Sum of its digits is 1+2+6 = 9 and 126 is divisible by 9.
Answer:
Question 9:
Write a program to initialize the seven Wonders of the World along with their locations
in two different arrays. Search for a name of the country input by the user. If found,
display the name of the country along with its Wonder, otherwise display “Sorry Not
Found!”. [15]
Seven wonders — CHICHEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL
OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations — MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example — Country Name: INDIA Output: INDIA-TAJMAHAL
Country Name: USA Output: Sorry Not Found!
Answer:
COMPUTER APPLICATIONS
(Theory)
(Two hours)
Answers to this Paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 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.
Question 1.
(b) What is meant by a package? Name any two Java Application Programming
Interface packages. [2]
(d) State one difference between floating point literals float and double. [2]
(e) Find the errors in the given program segment and re-write the statements correctly
to assign values to an integer array.
int a = new int( 5 );
for( int i=0; i<=5; i++ ) a[i]=i; [2]
Question 2.
(a) Operators with higher precedence are evaluated before operators with relatively
lower precedence. Arrange the operators given below in order of higher precedence
to lower precedence.
(i) && (ii) % (iii) >= (iv) ++ [2]
(b) Identify the statements listed below as assignment, increment, method invocation or
object creation statements.
(i) System.out.println("Java");
(ii) costPrice = 457.50;
(iii) Car hybrid = new Car();
(iv) petrolPrice++; [2]
(c) Give two differences between switch statement and if-else statement. [2]
(d) What is an infinite loop? Write an infinite loop statement. [2]
(e) What is a constructor? When is it invoked? [2]
Question 3.
(a) List the variables from those given below that are composite data types.
(i) static int x; (iv) boolean b;
(ii) arr[i]=10; (v) private char chr;
(iii) obj.display(); (vi) String str; [2]
2
T14 861
(c) What are the final values stored in variables x and y below?
double a = − 6.35;
double b = 14.74;
double x = Math.abs(Math.ceil(a));
double y = Math.rint(Math.max(a,b)); [2]
(d) Rewrite the following program segment using the if-else statements instead of the
ternary operator.
String grade = (mark>=90) ? "A" : (mark>=80) ? "B" : "C"; [2]
(e) Give output of the following method:
public static void main(String[] args) {
int a = 5;
a++;
System.out.println(a);
a − = (a− −) − (− −a);
System.out.println(a); } [2]
(f) What is the data type returned by the library functions:
(i) compareTo()
(ii) equals() [2]
(g) State the value of characteristic and mantissa when the following code is
executed.
String s = "4.3756";
int n = s.indexOf('.');
int characteristic = Integer.parseInt(s.substring(0,n));
int mantissa = Integer.valueOf(s.substring(n+1)); [2]
(h) Study the method and answer the given questions.
public void sampleMethod()
{ for( int i=0; i<3; i++ )
{ for( int j=0; j<2; j++)
{ int number = (int)(Math.random() * 10);
System.out.println(number); }}}
(i) How many times does the loop execute?
3
(ii) What is the range of possible values stored in the variable number? [2]
The answers in this Section should consist of the Programs in either Blue J environment
or any program environment with Java as the base.
Each program should be written using Variable descriptions/Mnemonic Codes
such that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required.
Question 4.
4
Member Methods:
(i) movieMagic() Default constructor to initialize numeric data members to 0 and
String data member to "".
(ii) void accept() To input and store year, title and rating.
(iii) void display() To display the title of a movie and a message based on the rating as
per the table below.
Write a main method to create an object of the class and call the above member methods. [15]
Question 5.
A special two-digit number is such that when the sum of its digits is added to the product
of its digits, the result is equal to the original two-digit number.
Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits= 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the product of
its digits. If the value is equal to the number input, output the message “Special 2-digit
number” otherwise, output the message “Not a Special 2-digit number”. [15]
Question 6.
Write a program to assign a full path and file name as given below. Using library functions,
extract and output the file path, file name and file extension separately as shown.
Input C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg [15]
5
Question 7.
area = ( − )( − )( − )
where s =
(ii) double area(int a, int b, int height) with three integer arguments, returns the area of a
trapezium using the formula:
(iii) double area(double diagonal1, double diagonal2) with two double arguments, returns
the area of a rhombus using the formula:
Question 8.
Using the switch statement, write a menu driven program to calculate the maturity amount
of a Bank Deposit.
The user is given the following options:
(i) Term Deposit
(ii) Recurring Deposit
For option (i) accept principal(P), rate of interest(r) and time period in years(n). Calculate
and output the maturity amount (A) receivable using the formula A= P 1+
For option (ii) accept Monthly Installment (P), rate of interest(r) and time period in months
(n). Calculate and output the maturity amount(A) receivable using the formula
( )
A=P×n+P× × ×
6
Question 9.
Write a program to accept the year of graduation from school as an integer value from the
user. Using the Binary search technique on the sorted array of Integers given below,
output the message “Record exists” if the value input is located in the array. If not, output
the message “Record does not exist”.
{1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010} [15]