Article archive

Array programs uploaded

17/10/2013 20:36
Friends, I have uploaded array programs and they all are checked and are not giving a single error. So you can easily copy down 

Sort an array using selection sort

17/10/2013 20:18
public static void main(String args[]) { int[]a={12,33,1,3,2,5}; int b=a.length; int max; int p; for(int i=0;i<=b-1;i++) { max=a[i]; p=i; for(int j=i+1;j<b;j++) { if(a[j]>max) { max=a[j]; p=j; } } a[p]=a[i]; a[i]=max; } for(int...

Sort an array using bubble sort

17/10/2013 17:44
public class bubblesort { public static void main(String args[]) { int[]a={25,12,32,90,1}; int b=a.length; int t; for(int i=0;i<=b-1;i++) { for(int j=0;j<b-1;j++) { if(a[j]>a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } } for(int...

Accept two string values from user and find out their length,convert them into upper case and lower case and check whether they are equal

04/07/2013 11:46
import java.io.*; public class acceptingvalues { public static void main(String args[])throws IOException { InputStreamReader ir=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(ir); System.out.println("enter two strings"); String a=br.readLine(); String...

What is a constructor in java?

29/03/2013 07:16
Generally constructors are those functions which have same function name as class name.They are also called as special types of fuinctions used to initialize the objects.However there are some restrictions in constructors which are not there in an ordiary functions.They are as follows Only...

Write a program to calculate area of rectangle. Define a parametrized function "rect" to find area of rectangle

20/03/2013 00:45
  public class rectangle {  void rect(int a,int b)  {  int area=a*b;  System.out.println(area); } public static void main(String args[]) { rectangle ob1=new rectangle(); ob1.rect(5,10); } }

Write a program with function "calculate" to except the time in minutes and convert in hours

20/03/2013 00:23
  public class converter { static double minute=30; static double b=60; static void calculate() { double hour=minute/b; System.out.println(hour); } public static void main(String args[]) { calculate(); } }

Write a program with function "convert" which takes the temperature in Celsius and converts the equivalent Fahrenheit value

20/03/2013 00:10
  public class abc { static double a=1.8; static double c=100; static double b=32; static void convert() { double farenheit=a*c+b; System.out.println(farenheit); } public static void main(String args[]) { convert(); } }

To print area of rectangle

18/03/2013 08:28
  public class areaofrectangle {  public static void main(String args[])  {  int length=5;  int breadth=9;  int area=length*breadth;  System.out.println("area of rectangle is"+" "+area); } }

To print whether the number is perfect or not

18/03/2013 08:27
  public class perfectnumbers { public static void main(String args[]) { int a=6; int sum=0; for(int i=1;i<a;i++) { if(a%i==0) { sum=sum+i; } } if(sum==a) System.out.println("the number is perfect"); else System.out.println("the number is...
Items: 11 - 20 of 39
<< 1 | 2 | 3 | 4 >>