I /IF ELSE/ IF ELSEIF/ NESTED IF/ SWITCH QUESTIONS
1. Montauk Company has decided to make their commission structure more
aggressive for their sales department as follows.
Sales Grade Commission
10,000 1 10%
2 8%
<=10,00 -- 5%
0
2. WAP to find the roots of a quadratic equation given by ax 2 + bx + c =0 If
b2- 4ac > 0 then print the roots are real and unequal
Rootl = ********** Root2 = *************
2a 2a v If b - 4ac = 0 then print the, roots are real and equal.
Root= — la
If b2- 4ac < 0 then print the roots are complex and imaginary.
3. The rates of income tax applicable on income of the individuals for the
assessment year 2003-2004 were as follows.
Net income Range Rates of Income Tax
Up to Rs 50000 Nil
Above Rs. 50000 but up 10% of the amount by which
to Rs. 60000. the
total income exceeds Rs.
50000
Above Rs. 60000 but up Rs. 1000 plus 20% of the
to Rs 150000. amount by which the total
income exceeds Rs. 6
thousand
Above Rs. 150000 Rs. 19000 plus 30% of the
amount by which the total
income exceeds Rs. 150000.
4. XYZ Company gives allowances to its employees depending on their grade as
follows.
Grade Allowances
A 300
B 250
Others 100
Calculate the Salary at the end of the month
5. The monthly electricity bill is to be computed as follows:
Minimum Rs. 250 for the first 100 units
Plus Rs. 0.40 per unit for next 50 units
Plus Rs. 0.50 per unit for next 50 units
Plus Rs. 0.60 per unit for next 50 units
WAP which calculates the monthly bill based on the number of units
consurned.
6. Any character is entered through the key board, write a program to determine
weather the character entered is a capital letter, a small case letter,, a digit or a
special character.
Character ASCII values
A-Z 65-90
a-z 97-122
0-9 48-57
Special symbols 0-47,58-64,91-
96,123,127
7. An insurance company follows following rules to calculate premium.
a. If a person’s health is excellent and the person is between 25 and 35 years of
age and lives in a city and is a male then the premium is Rs. 4 per thousand and
his policy amount can not exceed Rs. 2 Lakhs.
b. If a person’s satisfied all the above conditions except that the sex is female
then the premium is Rs. 3 per thousand and her policy amount can not exceed
Rs. 1 Lakhs.
c. If a person’s health is poor and the person is between 25 and 35 years of age
and lives in a village and is a male then the premium is Rs. 6 per thousand and
his policy amount can not exceed Rs. 10,000.
d. In all the other cases the person is not insured.
WAP to output whether the person should be insured or not, his/her premium
rate and maximum amount for he/she can be insured.
8. WAP to create a menu driven program to do the following:
a. Area of Rectangle
b. Diagonal of Rectangle
c. Perimeter of Rectangle
9. WAP to input the aggregate percentage and assign the respective stream as per
the following conditions:
Aggregate % Stream
>90 Science with computers
80-89 Science with Hindi
70-79 Commerce with computers
60-69 Commerce with Hindi
Using a switch statement, write a menu driven program to convert a given
temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice,
an appropriate error message should be displayed.
C=5/9 * (F-32) and F=1.8* (C+32)
10. WAP to create a class salary to input the name, address, phone, subject,
monthly salary, income tax and compute the annual income tax as 5% of the
annual salary above Rs. 1,75,000/=. Display all the details after calculations.
11. A cloth showroom has announced the following festival discounts on the
purchase of items, based on the total cost of the items purchased: -
Total Cost Discount (in %)
Less than Rs. 2000 5%
Rs 2001 to Rs. 5000 25%
Rs. 5001 to Rs 10000 35%
Above 10000 50%
Write a program to input the total cost and to compute and display 4he amount
to be paid by the customer after availing the discount
12. Normally a year is said to be a leap year if it is divisible by 4. But if the year is
century year then it is not a leap year unless divisible by 400. For example
year 1996 was a leap year. Century year 2000 was also a leap year but century
year 2100 will not be a leap year as it is not divisible by 400. WAP program to
accept a year and print the message whether the year entered is a leap year or
not.
13. WAP to input the code of a particular item, the quantity purchased and the rate
calculate the total purchase amount and print it along with the gift to be
presented. The gift to the customer is given on the following basis:
Amount of purchase (Rs) Gift
100 and above but less than 500 A key chain
500 and above but less than 1000 A leather purse
1000 and above A pocket calculator
At the end of the bill Thank You' must be printed.