Posts

Accept a number the display the table of that number in java

 Accept a number the display the table of that number in java import  java.util.Scanner; public   class   DisplayTable {      public   static   void   main ( String   args []){          int   number ;          Scanner   input = new   Scanner ( System . in );          System . out . println ( "Enter a number " );         number =  input . nextInt ();          System . out . println ( "Table of " +number);          for ( int   i = 1 ;i<= 10 ;i++){          System . out . println (number+ " x " +i+ " = " +number*i);         }   ...

Create a program that will accept the salary of an employee and bonus to it in java

 Create a program that will accept the salary of an employee and bonus to it in java import  java.util.Scanner; public   class   AddIncrement {     public   static   void   main ( String   args []){      double   salary  ,  bonus  ,  new_salary ;      Scanner   input  =  new   Scanner ( System . in );      System . out . println ( "Enter the salary" );     salary =  input . nextDouble ();      System . out . println ( "Enter Bonus % of the salary" );     bonus =  input . nextDouble ();     new_salary=salary+(salary*bonus/ 100 );      System . out . println ( "The new salary is " +new_salary);     }  } Enter the salary 100 Enter Bonus...

Write a Java program, in which you input 2 numbers and find the sum and product of the two number in java

 Write a Java program, in which you input 2 numbers and find the sum and product of the two number in java import  java.util.Scanner; public   class   SumProduct {     public   static   void   main ( String   args []){         int   num1 , num2 , product , sum ;      Scanner   input  =  new   Scanner ( System . in );      System . out . println ( "Enter the 1st number" );     num1= input . nextInt ();      System . out . println ( "Enter the 2nd number" );     num2= input . nextInt ();     sum=num1+num2;     product=num1*num2;      System . out . println ( "Sum of " +num1+ " and " +num2+ " is " +sum );      System . out . println ( "...

Write a program to check a year is leap year or not in java

 Write a program to check a year is leap year or not in java public   class   LeapYear {     public   static   void   main ( String   args []){      int   year = 2013 ;      if (year% 4 == 0 ){          if (year% 100 == 0 ){              if (year% 400 == 0 ){              System . out . println ( "LeapYear" );             } else {              System . out . println ( "Not a LeapYear" );             }         } else {              System . out . printl...

Write a program to find LCM of two number in java

 Write a program to find LCM of two number in java public   class   LCM {      public   static   void   main ( String   args []){          int   number1 = 18 ,number2= 36 ,lcm;                   if (number1>number2){         lcm=number1;         } else {         lcm=number2;         }                   while ( true ){              if (lcm%number1== 0  && lcm%number2== 0 ){              System . out . println ( "The LCM of...

Write a program to find HCF of two number in java

 Write a program to find HCF of two number in java public   class   HCF {      public   static   void   main ( String   args []){      int   number1 = 13 ,number2= 117 ,hcf= 1 ;      for ( int   i = 1 ; i<=number1 && i<=number2;i++){          if (number1%i== 0  && number2%i== 0 ){         hcf=i;         }     }      System . out . println ( "HCF of " +number1+ " and " +number2+ " is " +hcf);     } } Output HCF of 13 and 117 is 13

Write a program to check a number is Automorphic or not in java

Image
 Write a program to check a number is Automorphic or not in java public   class   Automorphic {      public   static   void   main ( String   args []){          int   number =  376 ,digit= 0 ,temp,square,last;         temp=number;         square=number*number;          while (temp!= 0 ){             digit++;             temp=temp/ 10 ;         }                  last=square % ( int ) Math . pow ( 10 ,digit);          if (number==last){        ...