Java Assignments To Be Completed For Icse 2015 Practical File
Java Assignments To Be Completed For Icse 2015 Practical File
Topic: Functions
Assignment: 5
Design the following functions in a class special:
int fact(int q) to find and return the factorial of q
voidprintnumbers() by invoking function fact() find and print special numbers
between 10 and 200.
If sum of factorial of each digits of a number is equal to the given number itself, then the
number is said to be a special number.
For example- if n = 145 = 1! + 4! + 5! = 1 + 24 + 120 = 145 145 is a special number and
Factorial of n is defined as n! = n x (n-1) x (n-2) x.x 3 x 2 x 1
Assignment 6:
Write a program to perform to declare a class Numberprob with function generate( ) to do
the following operations by using the overloading concept:
a) generate( ): To use the function with an integer type argument to generate Fibonacci
series up to given value.
b) generate( ): To use the function with two integer type arguments to print the perfect
numbers between both the values.
Perfect number is the number which is equal to the sum of its factors. For e.g.
6=1+2+3
Assignment 7:
Design a class to overload a function compare ( ) as follows:
(a) void compare (int, int) to compare two integer values and print the greater of the two
integers.
(b) void compare (char, char) to compare the numeric value of two character with higher
numeric value
(c) void compare (String, String) to compare the length of the two strings and print the
longer of the two.
Assignment 8:
Design a class to overload a function polygon() as follows:
(i) void polygon(int n, char ch) with one integer argument and one character type argument
that draws a filled square of side n using the character stored in ch.
(ii) void polygon(int x, int y) with two integer arguments that draws a filled rectangle of
length x and breadth y, using the symbol @
(iii) void polygon( ) draw a pattern of * with two rows and 3 columns
Example:
(i)
(ii)
Output: OO
OO
Input value of x = 2, y = 5
Output: @@@@@
@@@@@
(iii)
Output: * * *
***
Assignment 9:
Assignment 10:
Define a class called mobike with the following description:
Instance variables/data members:
[15]
PhoneNo.
No. of days
Charge
Assignment 12:
Using the switch statement, write a menu driven program:
(i) To check and display whether the number input by the user is a composite number or not
(A number is said to be a composite, if it has one or more than one factors excluding 1 and
the number itself).
Example: 4, 6, 8, 9,
(ii) To find the smallest digit of an integer that is input:
Sample input: 6524
Assignment 14:
Write a menu driven program that takes users choice and output the outcomes of the
following evaluations based on the number N entered by the user using MATH class
functions. (Also use switch case).
1.
2.
3.
4.
Assignment 15:
The International Standard Book Number (ISBN) is a unique numeric book identifier, which
is printed on every book. The ISBN is based upon a 10-digit code. The ISBN is legal if
1*digit1 + 2*digit2 + 3*digit3 + 4*digit4 + 5*digit5 + 6*digit6 + 7*digit7 + 8*digit8 +
9*digit9 + 10*digit10 is divisible by 11.
Example: For an ISBN 1401601499
Sum=1*1 + 2*4 + 0*0 + 4*1 + 5*6 + 6*0 + 7*1 + 8*4 + 9*9 + 10*9 = 253 which is divisible
by 11.
Write a program to:
(i) input the ISBN code as a 10-digit number
(ii) If the ISBN is not a 10-digit number, output the message Illegal ISBN and terminate
the program
(iii) If the number is 10-digit, extract the digits of the number and compute the sum as
explained above.
If the sum is divisible by 11, output the message Legal ISBN. If the sum is not divisible by
11, output the message Illegal ISBN.
Topic: String
Assignment 16:
Write a program to accept a word and convert it into lowercase if it is in uppercase, and
display the new word by replacing only the words with the character following it.
Example
Sample Input : computer
Sample Output : cpmpvtfr
Assignment 17:
Write a program that encodes a word in Piglatin. To translate word into Piglatin word,
convert the word into uppercase and then place the first vowel of the original word as the
start of the new word along with the remaining alphabets. The alphabets present before the
vowel being shifted towards the end followed by AY.
Assignment 18:
Write a program to input any string and count the total number of characters, vowels
presents in the string and also opposite case of the string.
Example:
Input: String: Application
Output:
Total Number of Characters:
11
Number of Vowels:
5
Opposite String:
aPPLICATION
Assignment 19:
Write a program to accept a string and display the same in reversed order.
Example:
Input:
Computer is fun.
Output:
fun is Computer
Assignment 20:
Write a program to accept a sentence and print the smallest word of the given sentence.
Assignment 21:
Write a program to accept a string. Convert the string to uppercase. Count and output the
number of double letter sequences that exist in the string.
Sample Input: SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLE Sample
Output: 4
Assignment 22:
Write a program to input a string in uppercase and print the frequency of each character.
INPUT : COMPUTER HARDWARE OUTPUT :
CHARACTERS
FREQUENCY
Topic: Arrays
Assignment 23:
Write a program to accept the names of 10 cities in a single dimension string array and their
STD (Subscribers Trunk Dialing) codes in another single dimension integer array. Search for
a name of a city input by the user in the list. If found, display Search Successful and print
the name of the city along with its STD code, or else display the message Search
Unsuccessful, No such city in the list.
Assignment 24:
Write a program to input 10 integers in an Array and sort them in descending order using
bubble sort and then finally print the sorted array.
Assignment 25:
Write a program to input and store the names of n Employees of a departmental store in an
array. Where n is input by the user. Then accept any name to be searcher in the array using
binary search technique. IF found display its position in array else display search employee
not found.
Assignment 26:
The annual examination of 50 students in a class is tabulated as follows.
Roll no.
Math
Science
Social Studies
---------------------------Write a program to read the data, calculate and display the following:
a)
Total marks obtained by each student
b)
Print the roll number and average marks of the students whose average mark is above
80.
c)
Print the roll number and average marks of the students whose average mark is below
40.
Assume each student studies only 3 subjects and maximum marks for each subject is 100.
Assignment 27:
According to the census of India 2001 following is the rounded off percentage of the urban
population in 10 states of India.
State
Percentage of urban population
1.
Jammu and Kashmir
25
2.
Himachal Pradesh
10
3.
Punjab
34
4.
Haryana
29
5.
Delhi
93
6.
Uttar Pradesh
21
7.
Bihar
10
8.
Madhya Pradesh
27
9.
Maharashtra
42
10. Tamil Nadu
44
Write a program to sort the above list in ascending order according to the percentage of
urban population using selection sort technique. The program should also print the names of
those states and their urban population, whose percentage of urban population is more than
40.