Java application Help?

Java application Help?

Write an application that can hold five doubles in an array. Display the doubles from first to last, and then display the doubles from last to first. Save the file as DblArray.java. Use the logic for a BubbleSort to sort and display your array in sequence

View Answers

October 17, 2011 at 10:48 AM

public class DblArray{
  public static void main(String a[]){
  int i;
  double array[] = {12,9.5,4.5,6,4.2};
  System.out.println("Values from first to last:\n");
  for(i = 0; i < array.length; i++)
  System.out.print( array[i]+"  ");
  System.out.println();

  System.out.println("Values from last to first:\n");
  for(i = array.length-1; i>=0; i--)
  System.out.print( array[i]+"  ");
  System.out.println();
  System.out.println();
  bubble_srt(array, array.length);
  System.out.print("Values after the sort:\n");
  for(i = 0; i <array.length; i++)
  System.out.print(array[i]+"  ");
  System.out.println();
   }

  public static void bubble_srt( double a[], int n ){
  int i, j;
  double t=0;
  for(i = 0; i < n; i++){
  for(j = 1; j < (n-i); j++){
  if(a[j-1] > a[j]){
  t = a[j-1];
  a[j-1]=a[j];
  a[j]=t;
  }
  }
  }
  }
}









Related Tutorials/Questions & Answers:
ModuleNotFoundError: No module named 'helpy'
ModuleNotFoundError: No module named 'helpe'
Advertisements
Please HELPP
Helps with combo box and frame
Java Application
Java application - Java Beginners
Java Client Application
Java Client Application example
Java HTML Client Application
JAVA APPLICATION - Java Beginners
Batch file for java application
java Application to java Applet
Java application - Java Beginners
java reminder Application
java reminder Application
Fingerprint application with Java
java application - Framework
Write a java application program........?
Fax service in Java application.
chat application - Java Beginners
Java application PLZ ?
Drools Application in Java
Java web Application
Problem in uploading java application
Fingeprint matching in java application
Distributed application and java
Constructing Application of Java
Java application Help?
java web application - Ant
Java application that uses the classes and
Java application - JDBC
Java application help!
Java application Help?
deploy java application
java chat application
java chat application
java application - Applet
Java Spring Desktop application
online test application in java
java spring simple application
Dojo: How MenuItem helps page redirction - Ajax
java application - JDBC
deploy application - Java Beginners
Java Bouncing Application
online test application in java
Java swimming application
java application/applet - Java Beginners
convert java Application to Java Applet
convert java Application to Java Applet
Java Application change to java applet

Ads