Can someone please! Fix this for me?

My program :
loop reads 10 double numbers
after that
inserts them into an array list.
after that
print MAx and MIn And AVg

THIS MY PROGRAM WHY I CAN NOT MAKE COMPILE Fix this for me :

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;




public class Program {

        public static void main(String[] args) {
      Scanner in = new Scanner(System.in);
    ArrayList<Double> numberz = new ArrayList<>();
    double sum = 0.0;
    double avg = 0.0;
    System.out.println("Enter 10 numbers, New line for each Input.");

    for (int i = 0; i < 10; i++)
    numberz.add(in.nextDouble());

    for (int i = numberz.size() -1; i >= 0; i--)

    sum = sum + numberz.get(i);
            Object maxRe = Collections.max(numberz);
            Object minRe = Collections.min(numberz);
            avg = sum/10;

            System.out.println("Maximum = " + maxRe);
            System.out.println("Minimum = " + minRe);
            System.out.println("Average = " + avg); 
    }

}

Recommended Answers

All 13 Replies

I'll help you to fix it.
What exacetly does the compiler error message say?

i have not any result
i do not know where is the mistake

use the site to try it

http://ideone.com/

Does it compile without errors?
Can you run it without getting an error message?
If you can run it, what data did you enter?

ps: You will do a lot better if you install the current Java Development Kit on your own machine.

Does it compile without errors? YES
Can you run it without getting an error message? YES
If you can run it, what data did you enter?
WORK PROGRESS AND STUCK WITHOUT RESULT
I USE NETBEANS IDE

sesaso: if you can't get something like that to compile and run, you may want to stop using netbeans.

if it runs, have you tried debugging, or just putting print statements in between to check what part of your code actually runs ?

Netbeans is good.

Dd you see the prompt for "enter 10 numbers"?

stultuske : THE OUTPUT
Enter 10 numbers, New line for each Input.

AFTER THAT PROGRAM HANG LIKE infinity LOOP

AND NO COMPLETE THE PROGRAM

JamesCherrill :
Dd you see the prompt for "enter 10 numbers"? NO

I just ran your code in NetBeans and it worked just fine.

You just told stultuske that your output was "enter 10 numbers", and told me that you did not see that prompt. Which is true?

Did you enter 10 numbers?

Which is true? yes i see it

Did you enter 10 numbers? i can not enter any number

my program idea is :
loop reads 10 double numbers
after that
inserts them into an array list.
after that
print MAx and MIn And AVg

put this code not work like i want
why?
how i can do it ?

I ran your program. It does work OK. It does exactly what you just said it should do. There's something wrong with how you are using it in NetBeans. The program itself is OK.

After you see the prompt, click in the NetBeans output window (where you saw the prompt) and type the 10 numbers as instructed.

THANK YOU ..
ITS WORK NOW :)

OK!!!

Next time, please be more careful with how you describe your problem. The more accurate and complete it is, the quicker you will get the right answer.

OK Teacher :)

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.