Skip to main content

Posts

Showing posts from August, 2013

Binary Seach

/**Binary Search*/ import java.util.*; public class Binarysearch {     public static void main(String [] args)     {         Scanner input = new Scanner(System.in);         final int SIZE = 30;         System.out.println("Enter the Number Of elements you want to enter ");         int n = input.nextInt();         System.out.printf("Enter %d elements \n",n);         int i=0,j=0;         int [] arr = new int [SIZE];         for(i=0;i<n;i++)         {             arr[i]=input.nextInt();         }         //sor...

A Corporation needs a program to calculate how much to pay to their hourly employees. The corporation requires that employee get paid time and a half for any hours over 35 that they work in a single week. For example if an employee work 42 hours, he get 7 hours overtime, at 1.5 times his base pay. The corporation requires that hourly employees be paid at least Rs.50 per hour. The corporation also requires that employee should not work more than 60 hours in a week. Write a program in Java which take base pay and no. of hours an employee works in a week as input, and compute the pay for hourly employee.

A Corporation needs a program to calculate how much to pay to their hourly employees. The corporation requires that employee get paid time and a half for any hours over 35 that they work in a single week. For example if an employee work 42 hours, he get 7 hours overtime, at 1.5 times his base pay. The corporation requires that hourly employees be paid at least Rs.50 per hour. The corporation also requires that employee should not work more than 60 hours in a week. Write a program in Java which take base pay and no. of hours an employee works in a week as input, and compute the pay for hourly employee. import java.util.*; public class Salary {     public static void main(String [] args)     {         Scanner input = new Scanner(System.in);         System.out.println("Enter Base Pay of the employee in hours(base pay always > 50)");         int...

Write a program to convert a decimal number into hexadecimal number system.

Write a program to convert a decimal number into hexadecimal number system. import java.io.*; public class DecToHex {     public static void main(String [] args)throws IOException     {         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));         System.out.println("Enter Decimal Number");         int a = Integer.parseInt(br.readLine());         int n=0,r=0;         String str ="";         while(a>0)         {             r=a%16;             //System.out.println(r);             a=a/16;    ...
/** To print diagonal elements of a matrix and its Sum*/ import java.util.Scanner; public class DiagonalElements {     public static void main(String [] args)     {         int i,j;         final int SIZE =3;            Scanner input = new Scanner(System.in);         int [][] arr = new int [SIZE][SIZE];                 System.out.println("Enter Array Elements");                for(i =0; i<3;i++ )         {             for(j=0;j<3;j++)             {                 arr[i][j] = input.nextInt(); ...

To find the gcd and lcm of a number

 To find the gcd and lcm of a number /*import java.util.Scanner; public class Gcd_Lcm {     public static void main(String [] args)     {         Scanner input = new Scanner(System.in);         System.out.println(" Enter num1");         int num1 = input.nextInt();             System.out.println(" Enter num2");                int num2 = input.nextInt();         int gcd=1;         int k = 2;         while(k<num1 && k< num2)         {                         if(num1%k ==0 && num2%k==0)     ...

convert Decimal numbers in octal Representation

 convert Decimal numbers in octal Representation /*import java.io.*; import java.util.*; public class Octal {     public static void main(String [] args)     {         Scanner input = new Scanner(System.in);         System.out.println(" Enter Number ");         int num = input.nextInt();         int temp = num;         String b=null;         while(temp>0)         {             int a;             a=temp%8;             temp=temp/8;             if(b==null) ...

converting decimal integer into binary number

 Converting decimal integer into binary number /*import java.io.*; import java.util.*; public class Binary {     public static void main(String [] args)     {         Scanner input = new Scanner(System.in);         System.out.println(" Enter Number ");         int num = input.nextInt();         int temp = num;         String b=null;         while(temp>0)         {             int a;             a=temp%2;             temp=temp/2;             if(b==null)       ...