Java Programing

 

Java Programming

Java Program

Conditional Statement in java:-

  1.  Enter any two digits number then check that number is a buzz number or not.

 

int a =7, b=17, n;

{

System.out.println(“enter any two digit number”);

If(n%7==0)||(n%10==7)||(n/10==7)

{

System.out.println(“buzz  number”);

System.out.println(“not buzz number”);

}

}

2.   Enter any three sides of the triangle then check triangle is possible or not.

 Scanner in = new Scanner (System.in);

int a , b, c;

System.out.println(“Enter any three angles”);

a =in.nextInt(); 

b = in.nextInt(); 

c = in.nextInt(); 

if ((a+b+c)==180 ͦ)

{

System.out.println(“triangle is possible”);

If (a==90||b==90|| c==90)

System.out.println(“Right angle triangle”);

If (a>90||b>90||c>90)

System.out.println(“obtuse”);

If (a<90||b<90||c<90)

System.out.println(“acute”);

{

else

System.out.println(“triangle is not possible”);

}

}

3.  Enter any three sides of the triangle then check the triangle is possible or not if possible then which type of triangle it is isosceles, scalene, or Equilateral.

 Scanner in = new Scanner (System.in);

int a, b, c;

System.out.println(“Enter any three sides”)

a = in.nextInt(); 

b = in.nextInt(); 

c = in.nextInt();

If ((a+b>=c) || (b+c>a) || (c+a>b))

{

System.out.println(“triangle is possible”);

If ((a==b) || (b==c))

Systemout.println(“Equitaral triangle”);

If ((a==b) || (b==c) || (c==a))

System.out.println(“Isoceles”);

If ((a!=b) || (b!=c) || (c!=a))

System.out.println(“Scalane”);

{

else

          System.out.println(“triangle is not possible”);

             }

}

4.  In a post office apply for parcel weight for every 1st kg Rs.15 and additional charges are Rs.8 for every 500gm then calculate charges.

int  charge = 15;

int weight;

System. out.println(“Enter weight in …..”);

{

If ( weigth <=1000)

System.out.println(“charge”);

If (weight >1000)

Charge = charge + ((weight-1000/500)*8);

System.out.println(“charge”);

}

 

Post a Comment

0 Comments