Txerrinko

Principal10Floats

Mar 18th, 2012
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package Ejercicio5;
  2.  
  3. import java.io.IOException;
  4.  
  5. public class Principal10Floats {
  6.  
  7.     /**
  8.      * @param args
  9.      * @throws IOException
  10.      */
  11.     public static void main(String[] args) throws IOException {
  12.         // TODO Auto-generated method stub
  13.  
  14.  
  15.         float[] posiciones = new float [10];
  16.         float num;
  17.         int i;   //los indices en los arrays seran tipo int
  18.         float previo=-20;
  19.    
  20.        
  21.         for (i=0; i<posiciones.length;i++){
  22.            
  23.             System.out.println("Introduce numero");
  24.             num=Consola.leeFloat();
  25.             if (num<previo )
  26.             {
  27.                 System.out.println("Numero menor al anterior");
  28.             }
  29.             else {
  30.                
  31.             posiciones[i]=num;      //intercambio posiciones
  32.              previo=num;
  33.             }
  34.         }
  35.        
  36.         //visualizara la posicion de cada array
  37.          for (i=0; i<posiciones.length;i++){
  38.              System.out.println("\r"+posiciones [i]);
  39.            
  40.                
  41.            
  42.         }
  43.            
  44.            
  45.            
  46.         }
Advertisement
Add Comment
Please, Sign In to add comment