1.
The Telephone Department bills
its subscribers on
the following basis :
Fixed
bi-monthly rental -- Rs. 250/-
Free calls for
two months -- 50
Charge
per call beyond
free
limit for next
100 calls -- 80
paise
Charge per call
for any call
exceeding
150 calls --
Rs 1.25
Create a
class with the
following specifications :
Class name : PhoneBill
I.V. : calls (int ) , bill_amt (double)
Methods :
public PhoneBill() : constructer
public void getcalls( int c) : to initialize
calls
public void
compute() : computes the bill amount
public void
show_bill() : displays the computed bill
amount
2.
Design a
class that will
sort an integer
array in Descending
order using the
Selection sort technique. Your
class must
include the following
members :
Class name : Sorter
I.V. : int list[]
( integer array ) , int size ( array size )
Methods :
public Sorter(int
s) : constructer that gets array size & allocates cells
public void readlist() : inputs integers in the
array
public void sort() : sorts the entire array in
Descending order
public int
indexofmax( int x) : returns the
index of the largest integer
in
the array
between x and
the last index
public void
swap( int x , int y) : interchanges the
contents of index x
and index y
Define all
functions except readlist() , which you may
assume has already
been defined.
3.
Consider two
rectangles :
the first rectangle with length of 4
units & width
of 5 units
the second rectangle with
length of 6 units
& width of 2
units .
Now , suppose we
want to derive
a third ( bigger ) rectangle whose length is the same as
the area of
the first rectangle
and whose width
is the same as the
area of the
second rectangle.
Therefore the
dimensions of the
third rectangle will
be :
length = 20
units ( 4 * 5)
width = 12 units
(6 * 2)
area = 240 units ( 20 * 12)
To perform the
above tasks , create a
class with the
following specifications :
Class name : Rectangle
I.V. : int
l , w ( denote length &
width )
Methods :
public Rectangle() : default constructer
public Rectangle( int x , int y) : parameterized constructer to initialize l & w
public void
disp() : displays the length , width & area
of present
Rectangle
public int
givearea() : returns the area of
current Rectangle
public Rectangle
giveDimensions( Rectangle r )
: returns the dimensions of the
derived
Rectangle using the current
Rectangle
and r.