You are on page 1of 9

1. WAP that will accept the size of an int array.

If the size is negative or less than 3 then display


message "Invalid Size"
and quit the program.
Accept input in array. Display the array in asc/descending order.

input format 1
5
16
30
20
18
19
output format1
16 18 19 20 30

input format 2
-9

output format2
Invalid Size

2. WAP that will accept the size of an int array.


If the size is zero or negative then display message "Invalid Size"
and quit the program.
Accept input in array.
Find all prime numbers in array.
Display their average value upto 2 decimal place.
If no prime number found then
display message "No prime number found"

input format 1
5
15
31
20
18
19
output format1
25.00

input format 2
-9

output format2
Invalid Size

input format 3
3
15
20
18

output format3
No prime number found
Q3. Accept size & values of an int array .
If the size is zero or negetive then display message "Invalid Size"
and quit the program.
Accept input in array,
1.each value must higher then 10 otherwise re-accept that number.
2.Find the odd numbers in it then ,
multiply the digits of each odd numbers and store the result
them in a second array in descending order.
hint :input:{24,45,11,14,23,70,18}
the odd numbers in the array{45,11,23}
multiply the digits of each number
4*5=20
1*1=1
2*3=6

output:20 6 1

Q4.wap that will accept a number between 1000 and 10000000.


Display second smallest digit.

input:6481937
output:3

Q5.Wap the will accept the size and elements in an int array.
*Find the repeating elements & arrange them in acsending order
in an output array.
*If the size is zero or negetive then display
"Invalid Size",
*if no repeating elements then display message "No Repeated Elements"
*if any element in input array is 0 or negetive then display message
"Invalid Input".

Q6. Write a program to illustrate the use of the method lastIndexOf()


defined in the string API.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output:

Enter the string

Amphisoft Technologies is a product company


Enter the string to be searched

is

The index of last occurence of "is" is 23

Enter the index limit

20

First occurence of "is" from 20th index backwards is 4

Q7. Write a program to illustrate the use of the method startsWith()


defined in the string API.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output 1:

Enter the string

Ampphisoft

Enter the start string

Amphi

"Ampphisoft" does not start with "Amphi"

Sample Input and Output 2:

Enter the string

Amphisoft

Enter the start string

Amphi

"Amphisoft" starts with "Amphi"


Q8. Write a program to illustrate the use of the method endsWith()
defined in the string API.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output 1:

Enter the string

Ampphisoft

Enter the end string

softi

"Ampphisoft" does not end with "softi"

Sample Input and Output 2:

Enter the string

Amphisoft

Enter the end string

soft

"Amphisoft" ends with "soft"

Q9. This program is to illustrate the use of the method split()


defined in the string API.

Write a program to split a string based on spaces


(There may be multiple spaces too) and returns the tokens
in the form of an array.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :

Enter the string

Indiasoft Technologies is a private organization

The words in the string are

Indiasoft

Technologies

is

private

organization

Q10. This program is to illustrate the use of the method


replace() defined in the string API.

Two companies enter into a Marketing Agreement and


they prepare an Agreement Draft.
After that one of the companies changes its name.
The name changes need to be made in the Agreement Draft as well.
Write a program to perform the name changes in the agreement draft.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :


Enter the content of the document

ITT is a private organisation. ITT is a product based company. DBox is a ITT


product

Enter the old name of the company

ITT

Enter the new name of the company

TTT

The content of the modified document is

TTT is a private organisation. TTT is a product based company. TTT is a Amphisoft


product

Q11. Write a program to remove multiple spaces in a string.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :

Enter the string

Java is an Object Oriented


Prog Language

The processed string is Java is an Object Oriented Prog Language

Q12. Write a program to print the input string vertically both


forwards and backwards.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :


Enter the string

Amphisoft Technologies

The string printed vertically forwards and backwards is

A s

m e

p i

h g

i o

s l

o o

f n

t h

T e

e T

h t

n f

o o

l s

o i

g h

i p

e m

s A

Q13. Given a string,


write a program to compute a new string where identical chars
that are adjacent in the original string are separated from
each other by a "*"
Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :

Enter the string

hello

The processed string is hel*lo

Q14. Given a string,


write a program to compute a new string where all
the lowercase 'x' chars have been moved to the end of the string.

Input and Output Format:

Refer sample input and output for formatting specifications.

All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :

Enter the string

Excellent AXE

The processed string is Ecellent AXEx

Q15. To "capitalize" a string means to change the first letter of each word in the
string to upper case (if it is not already upper case). For example, a capitalized
version of "Now is the time to act!" is "Now Is The Time To Act!". Write a program
to print the capitalized version of the input string.

Input and Output Format:

Refer sample input and output for formatting specifications.


All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output :

Enter the string

Java is an object oriented programming language

Capitalized version:

Java Is An Object Oriented Programming Language

You might also like