My homework goes like this: Write a program that accepts as many integers the user wants to input. Determine the highest and lowest numbers and subtract all other numbers from the highest number. example: numbers to be entered: 6 number1 :15 number2:20 number3:29 number4:38 number5:12 number6: 42
Output: Highest: 42 Lowest:12 [The difference from the highest is: [42-15]=27 [42-20]=22 <---how can i display them? [42-29]=13 [42-38]=4 [42-312]=30
Logically you don't know the highest number until all the numbers have been input, so to show all the differences you will have to store all the numbers (eg in an array) as they are input. Then, when you know the largest, you can loop through the array and disaply all the differences.
Sorry, but no. I'm no going to write your homework for you. Your teacher obviously thinks that you should know enough about arrays, or are ready to learn enough, so that's what you should do. Here a good place to start: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html It's up to you to try your best. There are plenty of people here who will help you if you do.