Search This Blog

UI/UX Design | Web Development | Mobile Application Development

Whether you need UI/ UX design, web development services, or mobile app development services, Qaabil Digitals will be more than happy to help you. We work with top software developers, designers, and project managers. We tailor our services to suit your exact needs. We closely look at your company, listen to your story, and bring about the best ideas and solutions that can help you drive solid results. We don’t just produce work that works. We produce work that matters. Get a quote now Or Talk to us

Thursday 21 April 2011

Java program to conver any integer into binary form

import java.util.*;
class binary
{
public static void main (String arg[])
{
Scanner in=new Scanner (System.in);
int a,d;
System.out.print ("\n\t Enter the number = ");
a=in.nextInt();
int b1,b2,b3,b4,b5,b6,b7,b8;

b1=a%2;
    d=a/2;
b2=d%2;
    d=d/2;

b3=d%2;
    d=d/2;

b4=d%2;
    d=d/2;

b5=d%2;
    d=d/2;

b6=d%2;
    d=d/2;

b7=d%2;
    d=d/2;

b8=d%2;
   
System.out.print ("\n\t Binary of "+a+" is = ");
System.out.print (b8);
System.out.print (b7);
System.out.print (b6);
System.out.print (b5);
System.out.print (b4);
System.out.print (b3);
System.out.print (b2);
System.out.print (b1);
}
}

Wednesday 20 April 2011

Java program to find the charecter value of any integer

import java.util.*;
class chvalue
{
public static void main (String arg[])
{
Scanner in=new Scanner (System.in);
int a,l=1;
char b;
while (l!=0 && l==1)
{
System.out.print ("\n\t Enter the number = ");
a=in.nextInt();
b=(char)a;
System.out.println ("\n\t Character value of the number = "+b);
System.out.print ("\n\t Enter 0 to terminate and 1 to re-run the program = ");
l=in.nextInt();
}
}
}

Java program which add two numbers and terminates only when user press 0

import java.util.*;
class sum
{
public static void main (String arg[])
{
Scanner in=new Scanner (System.in);
int a,b,p,l=1;
while (l!=0 && l==1)
{
System.out.print ("\n\t Enter first number = ");
a=in.nextInt();
System.out.print ("\n\t Enter second number = ");
b=in.nextInt();
p=a*b;
System.out.println ("\n\t Product of the numbers = "+p);
System.out.print ("\n\t Enter 0 to terminate and 1 to re-run the program = ");
l=in.nextInt();
}
if (l==2)
System.out.println ("\n\t Your program has some logical error");
else
System.out.println ("\n\t Program has been terminated");
}
}

Java program to calculate sum of even numbers

import java.util.*;
class sumeven
{
public static void main (String arg[])
{
Scanner in=new Scanner (System.in);
int a,b,c;
System.out.print ("\n\t Enter first number = ");
a=in.nextInt();
System.out.print ("\n\t Enter second number = ");
b=in.nextInt();
System.out.print ("\n\t Enter third number = ");
c=in.nextInt();
int s=0;
if (a%2==0)
{
s+=a;
System.out.println ("\n\t "+a+" is Even number");
}
else
System.out.println ("\n\t "+a+" is Odd number");
if (b%2==0)
{
s+=b;
System.out.println ("\n\t "+b+" is Even number");
}
else
System.out.println ("\n\t "+b+" is Odd number");
if (c%2==0)
{
s+=c;
System.out.println ("\n\t "+c+" is Even number");
}
else
System.out.println ("\n\t "+c+" is Odd number");
System.out.println ("\n\t Sum of even numbers = "+s);
}
}

Java program which tells that either the enterd year is leap or not

import java.util.*;
class leap
{
public static void main (String arg[])
{
Scanner in=new Scanner (System.in);
int a;
System.out.print ("\n\t Enter the year = ");
a=in.nextInt();
if (a%4==0)
System.out.println ("\n\t Leap Year ");
else
System.out.println ("\n\t Not Leap Year ");
}
}

Java program which calculates total pay of an employee including convaince allounce,house rent and bonus

import java.util.*;
class salary
{
public static void main (String arg[])
{
Scanner in=new Scanner (System.in);
int a,ca;
System.out.print ("\n\t Enter basic pay of the Employe = ");
a=in.nextInt();
ca=(a/100)*3;
float t,b=25,hr=(a*25)/1000;
t=a+ca+hr;
System.out.println ("\n\t Convaince allounce = "+ca);
System.out.println ("\n\t House rent = "+hr);
System.out.println ("\n\t Total pay = "+t);
if (t<=4500)
{
t+=1000;
System.out.println ("\n\t Total pay + bonus = "+t);
}
else if (t>4500 && t<=8000)
{
t+=2000;
System.out.println ("\n\t Total pay + bonus = "+t);
}
else
System.out.println ("\n\t Not defined");
}
}

Java program to calculate electricity bill

import java.util.*;
class bill
{
public static void main (String arg[])
{
Scanner in = new Scanner (System.in);
int a,b=0,c=1;
while (c<=6)
{
System.out.print ("\n\t Enter bill of month no "+c+" = ");
a=in.nextInt();
b+=a;
++c;
}
int avg=b/6;
System.out.println ("\n\t Average bill = "+avg);
if (avg>5000)
System.out.println ("\n\t Government will pay ");
else
System.out.println ("\n\t Paid ");
}
}

Java program which shows result of three subjects

import java.util.*;
class result
{
public static void main (String arg[])
{
Scanner in=new Scanner (System.in);
int a,b,c;
System.out.print ("\n\t Enter marks of first subject = ");
a=in.nextInt();
System.out.print ("\n\t Enter marks of second subject = ");
b=in.nextInt();
System.out.print ("\n\t Enter marks of third subject = ");
c=in.nextInt();
int t=a+b+c;
System.out.println ("\n\t Total marks = "+t);
if (t>=250)
System.out.println ("\n\t Good ");
else
System.out.println ("\n\t Fair");
}
}
Share