Points to remember:
a. No semi colon after the condition in if statement.
Section A
1. Re write the following using a ternary operator
i. if(income<100000) [ICSE 2007]
tax=0;
else
tax=12;
ii. if(p>=5500)
k=p*3/100;
else
k=p*10/100;
2. Re write the statements using if statements:
i. com=(sale>3000)?sale*2/100:0;
ii. net =(salary(200000)?salary – (7.33/100)*salary: salary – (5/100)*salary;
3. What is a block?
4. Write the differences between if and switch . [ICSE 2006]
5. Find the output:
int a=1;
int b=5;
b++;
if(b==5)
System.out.print(“ Value is five”);
else
System.out.print(“ Value is not five”);
Section B
1. Write a program to calculate the monthly electricity bill as per the following conditions.
Units Rate per unit
<=100 meter rent
for next 200 units Rs.1.00 per unit+rent
for next 200 units Rs.1.50 per unit+rent
for >500 units Rs.2.25 per unit+rent
Input the consumer name, units consumed.Claculate and print the bill amount .The meter rent is Rs.200.
2. A library fine is calculated using the conditions given below:
Days Fine
1 to 5 Rs 1.00 per day
6 to 10 Rs.1.50 per day
11 to 15 Rs.2.50 per day
>15 Rs.3.50 per day
3. A company provides motorbike on rent to its members only.Write a program to input the bike number,name,member id,number of days and calculate the rent to be paid.
Days Rate per day
first 7 days Rs.500 per day
next 7 days Rs.400 per day
>14 days Rs.200 per day
Print the output in the following format:
Bike No Customer Name Member ID No. of days Rent to be paid
No comments:
Post a Comment