Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

PROGRAMS ON DECISION CONSTRUCT – if else

1) Write a program to accept the number of days the bike is taken on rent,
based on the table given below.
DAYS AMOUNT per day
1- 4 40
5 – 12 55
>=13 65
Rent = Number of Days * Amount per day

2) Write a program to accept the price of the electronic item and calculates the
discount, along with the total amount payable, on the price, based on the table
given below.
PRICE DISCOUNT
< = 10000 15%
10001 – 25000 25%
> = 25001 35%
Discount = Price * Discount %
Total Amount = Price – Discount

3) Write a program to accept three sides of a Triangle.


If all the three sides are equal, print “ The three sides form an equilateral
triangle”.
If any two sides are equal, print “The three sides form an isosceles triangle”
If all three sides are unequal, print “The three sides form a scalene triangle”

4) Write a program which calculates the plane fares of an Employee with the following.
Class Name : EmpDet
Accept the values for the above variables and calculate fare according the table given below.
Salary Fare
sal >= 10000 and <=20000 3500 + 2% of Salary.
sal > 20000 and <=35000 4000 + 2.5% of Salary
sal > 35000 and <=45000 5000 + 4% of Salary.
5) Write a program to calculate the formulae based on the following expressions.
4x + y if x > 0
4x + y if x < 0 , where x and y are accepted from user.
6) Write a program to accept a number and check if is an Even positive or Even negative or
Odd positive or Odd negative number.
Ex : Sample Input : 4 - Even Positive Numbee
-6 – Even Negative Number
-27 - Odd Negative Number
100 - Even Positve number
7) Write program to accept a number and check if it is a Buzz number or not.
A Buzz number is a number which is divisible by 7 OR the last digit of the number is 7
Example : 17 is a Buzz Number (Last digit of the number is 7)
21 is a Buzz Number (It is divisible by 7)
8) Write a program to accept the year and check if it forms a Leap Year
A year is said to be a leap year if it DIVISIBLE BY 4 AND IS NOT DIVISIBLE BY
100 OR IS DIVISIBLE BY 400.
9) Write a program to find the roots of a Quadratic Equation
10) Write a program to calculate Simple Interest according to table given below.

Principal Time Rate


Less than equal to 10000 1 Year 10%
2Years 11%

>=10001 and <=20000 2 Years 12%


3 Years 13%

More than 20001 3 Years 15%


More than equal to 4 Years 18%

You might also like