You are on page 1of 9

JAVA ASSIGNMENTS TO BE COMPLETED FOR ICSE 2015 PRACTICAL FILE

Topic: Conditional Construct if..else and switch


Assignment-1 * already given to you
Assignment-2
A Company has announced the following festival bonus on the basic salary of employees:Basic Salary
Bonus
Less than Rs.3000
6%
Rs.3000 to Rs.7000
9.5%
Rs.7001 to Rs.12000
14%
Above Rs.12000
20%
Write a program to input the basic salary and to compute and display the amount to be
received by an employee after the bonus.
Assignment-3
An electronics shop has announced the following seasonal discounts on the purchase of
certain items
Purchase Amount in Rs.
Discount on Laptop
Discount on Desktop
Less than 20000
No discount
5%
20000 45000
7.5%
10%
45001 75000
5%
7.5%
Above 75000
10%
15%
Write a program to input the amount of purchase and the type of purchase (L for Laptop and
D for Desktop)by a customer. Compute and display the amount to be paid by a customer.
Assignment-4
Write a program to print the electricity bill of consumers based on the meter readings given
by the user. Program accepts the name of consumer and his/her meter reading, calculates his
total bill and prints the bill in formatted manner as shown below:
Madhya Pradesh Electricity Board
Bill for the month of: January
Name of consumer:
Fixed Rent (A):
Total Unit consumed:
Amount to be paid for the consumed units (B):
Total Bill (A+B):
The charges are as given below. A fixed amount of Rs. 200 is charged as rental every
month.
Meter Reading
First 200 units
Between 201 and 400
Above 400

Charges per unit


65 Paise
80 Paise
Rupees 1.20

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)

Input value of n = 2, ch=O

(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]

int bno to store the bikes number


int phno to store the phone number of the customer
String name to store the name of the customer
int days to store the number of days the bike is taken on rent
int charge to calculate and store the rental charge
Member methods:
void input( ) to input and store the detail of the customer.
void computer( ) to compute the rental charge
The rent for a mobike is charged on the following basis.
First five days

Rs 500 per day;

Next five days

Rs 400 per day

Rest of the days

Rs 200 per day

void display ( ) to display the details in the following format:


Bike No.

PhoneNo.

No. of days

Charge

Topic: Iterative and non-iterative statements (nested and non-nested Loops)


Assignment 11:
Write a menu driven program to perform the following . (Use switch-case statement)
(a)
(b)

To print the series 0, 3, 7, 15, 24 . n terms (value of n is to be an input by


the user).
To find the sum of the series given below:
S = + + 5/6 + 7/8 .. 19/20

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

Sample output: Smallest digit is 2


Assignment 13:
Write a menu driven class to accept a number from the user and check whether it is a prime
or Armstrong number or Automorphic number or Perfect number or a Special number
depending upon the choice entered by the user.
a) Prime Number: A number is called Prime if it is divisible by 1 and the number
itself. Example: 5, 7, 11 etc.
b) Armstrong Number: A number is called Armstrong if sum of the cube of digits of the
number is same as the number. Example: 153= 13+ 53+ 33
c) Automorphic Number : An automorphic number is the number which is contained in the
last digit(s) of its square. Example: 25 is an automorphic number as its square is 625 and 25
is present as the last two digits.
d) Perfect Number: A number is called Perfect if sum of the all its factor is same as the
number. Example: 6= 1+2+3
e) Special Number: A number is said to be a special number, if the sum of the factorial of the
digits of the number is same as the original number. Example- 145= 1!+ 4! +5! = 1+24+120

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.

Display Natural logarithm of the number.


Square root of the number
Absolute value of the number
Random number between 0 and 1

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.

You might also like