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

.. please help me.thanks

import java.util.*;

   public class HighestLowestDifference2324 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        double maxValue = Double.MIN_VALUE;
        double minValue = Double.MAX_VALUE;  
        double minValue1 = Double.MAX_VALUE; 
        double minValue2 = Double.MAX_VALUE; 

        int count = 0;
          double difference = 0; 

        System.out.println("Enter numbers. Terminate with Q.");
        while (input.hasNextDouble()) { 

            double Value = input.nextDouble();

            if (Value > maxValue) {
                maxValue = Value;
            }
            if (Value < minValue) {
                minValue = Value;
            }
            if (Value < minValue) {
                minValue1 = Value; }
                if (minValue == minValue1)   {
                minValue = Value; }
            if (Value < minValue1) {
                minValue2 = Value; }
                if (minValue1 == minValue2)   {
                minValue1 = Value; }
            }
                count++;  
                difference = maxValue-minValue;        
                {
        if (count > 0) {                                          
            System.out.println("Highest no. is: "  + maxValue);
            System.out.println("Lowest no. is: "  + minValue);
                System.out.println("The difference from the highest is: \n" + difference);
        }
           else {
            System.out.println("Have a good day!"); }
    }
}
}

that is my code... pls. help me. I can't show all the differences that I want to display.

What exactly is your question? - the code you posted displays the results.

I have to get the difference of the highest number and the rest..
for example, to get the differences: 27,22,13,4,30. when i use the code , it only shows 27.

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.

so I have to change all my codes into an array?.. but is it possible that an array contains numbers yet
to be input ?

... only if you have time travel!
You start with an array that's big enough, fill in the data and keep track of how many data were entered ( = how many of the array elements have been used)

SIR JAMES... i'M SORRY FOR ASKING SILLY QUESTIONS ..xD. can you pls. add that to my code and show it off?...
i dont't know how to do array, eh?..please. ^_^ –

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.

Ok. I understand. Thank you by the way.. ^^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.