Comp StXavier
Comp StXavier
vii) Given that int AD[-{{6, 3,9}, {12, 4, 16}, {17, 7, 5}}, what will be the value at A[1]/2]?
)t6 b) 3 c)7 d) 17
Xíx) Read the following text, and choose the correct answer:
An expression is composed of one or more operations.
expressions and relational or logical
Expressions in Java can be of the following types: arithmetic
expressions.
mixed expressions. In pure expressions, all the
Arithmetic expressions can be either pure expressions or operands are of different data types.
operands are of the same type and in mixed expressions the
Boolean expressions result in either true or false.
b)Write the prototype of a function charsearch which takes two parameters, a string and a character and returns
false otherwise (21
true if thecharacter is found in the string and
int a =50;
ABCO
{a= 100;}
void main()
int a=20;
ABCabc = new ABCO;
System.out. println(a+"+abc.a):
121
j)Give the output:
System.out.println(int)("dreams". charAt(2); 161
System.out. println("MISSISSIPPr" JastlndexOf('S'); C (2
SECTIONB
(Answer any four questions from this Section.)
Each program should be written using variable description / mnemonic codes so that the logic of theprogram is
clearly depicted.
Question 3
Design a class Bank to store the details of acustomer and enable transactions for the customer with th
bank. The details of the class is given below:
Class name : Bank
name stores the name of the customer
accno stores the account number
stores the principal arnount in decimals
amt
stores the transaction amount in decimals
Member functions/methods:
void input) theinstance variables
tO dccept the valuesof
updates the
accepts the amount and updatesthe principal as pp tamt
void deposit( ) as
void withdraw( ) accepts the amount and than the principal pp amt Ifthe
withdrawal amount tis more principal amount, then display the
"INSUFFICIENT BALANCE" Ifthe principal amount after
message
withdrawal is lesssthan 500, then a penalty is imposed by using the
formula p=p-(500-p)/10
void display( ) displays the details of the customer
Write a main function to create an object and invoke the methods. [15]
Question 4
Wite aprogram to accept a string in uppercase and print the frequency of each cnataver.
Eg. HARDWARE
CHARACTERS FREQUENCY
A
D 1
E
H 1
R
W 1 [15]
Question 5
Write a program to store the product name and unit price of 10 different products in two single dimensional
arrays. Sort the unit price of the products in descending order, using the selection sort method, and display
the correspondingly sorted product name and unit price with proper headings. [15]
Question 6
Write a program to overload a function count) as given below:
count(int n, intd)to Accept a number and adigit and count the number of times the digit is present in the
number.
count(String s) to Accept a sentence and count the number of words beginning with a vowel. [15]
Question 7
Using a switch statement, write a menu- driven program to do the following as per the user's choice :
Accept an integer and find and display if it is a Spy number or not.
ASpy number is a number where the sum of digits-product of digits.
Eg. 1412; 1+4+1+2=1x4x1x2-8
Accept an integer and find and display if it is a Trimorphic number or not.
ATrimorphic number is one whose cube ends with that number.
Eg.: N=49
N'= 117649
Foran incorrect choice, an appropriate error message should be printed. [15]
Question 8
Write a program to enter integers in a 3x4 2-D array. Find and print the largest number in each row of the
array. [15]