You are on page 1of 3

Q16)

package ifassignments;
public class Q16 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/* A library charges a fine for every book returned late. For first
5 days the fine is 50 paise, for 6-10
days fine is one rupee and above 10 days fine is 5 rupees. If yo
u return the book after 30 days your
membership will be cancelled. Write a program to accept the numb
er of days the member is late to
return the book and display the fine or the appropriate message.
*/
int latedays=5;
if(latedays<6)
{
System.out.println("You are late! Fine 50 paise!");
}
else if(latedays<10)
{
System.out.println("You are late! Fine 1 rupee!");
}
else if(latedays>10)
{
System.out.println("You are late! Fine 5 rupees!");
}
else if(latedays>30)
{
System.out.println("You are late! You membership shall be termin
ated!!");
}
}
}
Q17)
package ifassignments;
public class Q17 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/* If the three sides of a triangle are entered through the keyboard, write a pr
ogram to check whether
the triangle is valid or not. The triangle is valid if the sum of two sides is g
reater than the largest of
the three sides.*/
int a=7;
int b=3;
int c=9;

if (a>b && a>c && b+c>a)


{
System.out.println("Triangle is valid");
}

else if (b>c && b>a && a+c>b)


{
System.out.println("Triangle is valid");
}

else if (c>b && c>a && a+b>c)


{
System.out.println("Triangle is valid");
}
else
System.out.println("Triangle cannot exist");
}
}

Q18)
package ifassignments;
public class Q18 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
/* If the three sides of a triangle are entered through the keyb
oard, write a program to check whether
the triangle is isosceles, equilateral, scalene or right angled triangle.*/
int a=7;
int b=7;
int c=7;
if(a==b && b==c)
{
System.out.println("The given sides are those of an equilateral
triangle");
}
else if(a==b || b==c || a==c)
{
System.out.println("The given sides are those of an isosceles tr
iangle");
}
else
{
System.out.println("The given sides are those of a scalene trian
gle");
}
}
}

You might also like