You are on page 1of 3

Q. 8.

Write a java class to calculate the income tax by taking monthly salary of an employee based on
the following conditions: (15)

Annual income(Rs) Tax

Upto 130000 No tax

Between 130000 – 200000 15% of the amount exceeding over Rs.130000

From 200000 – 250000 Rs. 5000 + 20% of the amount exceeding over Rs. 2000000

Above 250000 30% of the amount exceeding Rs.250000

Q. 9. Write a java class to calculate and print the electricity bill to be paid by a customer. (15)

Assume that the customer pays a rent of Rs. 250.00 .

No. of units Charge per unit

Upto 100 units Rs. 1.50

For the next 100 units Rs. 2.00

For next 50 units Rs. 2.50

Beyond 250 units Rs. 4.00

Q. 4. Write the output: (5)

(a) b)

public class test public class result


{ {
public void main( ) public static void main( )
{ {
int a=5,b; char a= 'a' ;
b=2*a - - + - - a; System.out.println(+a);
System.out.print(+a+" "+b); a++;
System.out.println(a);
} }
} }

Q. 6. Digital World announces seasonal discount on the laptops in the given order. [15]

Cost of the laptop Discount


Rs.20,000 - Rs.30,000 10%
Rs.30,000 – Rs.40,000 15%
Rs.40,000 – Rs.50,000 18%
> = Rs.50,000 20%

An additional discount of 5% on all types of laptops is given. Sales tax is calculated at 12% on the
price after the discounts. Define a class to accept the cost of the laptop and print the amount payable
by the customer on purchase ( use constructor).(2)
Q) char ch = ‘F’;

int m = ch;

m = m + 5;

System.out.println(m + “” + ch);

Q) Write ax5 + bx3 + c as a java expression.

Q) What is the value of x1 if x = 5?

X1 = ++x – x++ + --x;

Q) int x =20, y = 10, z; What is the value of z in z = ++x * (y – –) – y ? Show the steps.

Q) int a = 0; if(a>0 && a<20)

A++;

Else a—;

System.out.println(a);

Q) int a= 5, b = 2,c; if (a>b || a ! = b) c = ++a+--b; System.out.print(c+ “ ”+a+ “ ”+b);

Q) Define a class taximeter having the following description:

Data members/instance variables

int taxino - to store taxi number

String name - to store passenger's name

int km - to store number of kilometres travelled

Member functions:

taximeter() -- constructor to initialize taxino to 0, name to “ ”and b to 0.

input() - to store taxino,name,km

calculate() - to calculate bill for a customer according to given conditions

kilometers travelled(km) Rate/km

1 km Rs 25

1 < km <= 6 Rs 10
6 < km <= 12 Rs 15

12 < km <= 18 Rs 20

>18 km Rs 25

display()- To display the details in the following format

Taxino Name Kilometres travelled Bill amount

----

Create an object in the main method and call all the above methods in it.

Q) (a)Evaluate the value of n if the value of p=5, q=19;

int n =(q-p)>(p-q)?(q-p):(p-q);

Ans : The value of n will be 14

(j) If int y = 10 then find int z = (++y*(y++ +5));

Write a program in to input and store all roll numbers, names and marks in 3 subjects
of n number of students in five single dimensional arrays and display the remark based
on average marks as given below

Average marks = total marks/3

Average marks Remark


85 – 100 EXCELLENT

75 – 84 DISTINCTION

60 – 74 FIRST CLASS

40 – 59 PASS

Less than 40 POOR

You might also like