Hi. i was asked to put 3 numbers in array, and print them by order of who's the highest one.
I am a beginner, so this code is supposed to be simple (no strings what so ever..)
package Maaracim; import MyPackage.MyConsole; public class Maarachim6 { public static void main(String[] args) { // TODO Auto-generated method stub int []Array = new int [3]; Array[0]= (int)MyConsole.readInt("leave first number"); Array[1]= (int)MyConsole.readInt("leave second number"); Array[2]= (int)MyConsole.readInt("leave third number"); int smallest=Array[0]; int between=Array[0]; int highest=Array[0]; for (int k = 0; k < Array.length; k++) { if (Array[k]<smallest) smallest = Array[k]; if (Array[k]>highest) highest = Array[k]; if ( Array[k]>smallest &&Array[k]<highest) between = Array[k]; } System.out.println("highest number is "+highest); System.out.println("between number is "+between); System.out.println("smallest number is "+smallest); }}