Question

Design a Java program that asks the user to enter
0 0
Add a comment Improve this question Transcribed image text
Answer #1

class ArrayDemo {

    public static void main(String[] args) {

        // declares an array of integers

        int[] anArray;

        // allocates memory for 10 integers

        anArray = new int[10];

          

        // initialize first element

        anArray[0] = 100;

        // initialize second element

        anArray[1] = 200;

        // and so forth

        anArray[2] = 300;

        anArray[3] = 400;

        anArray[4] = 500;

        anArray[5] = 600;

        anArray[6] = 700;

        anArray[7] = 800;

        anArray[8] = 900;

        anArray[9] = 1000;

        System.out.println("Element at index 0: "

                           + anArray[0]);

        System.out.println("Element at index 1: "

                           + anArray[1]);

        System.out.println("Element at index 2: "

                           + anArray[2]);

        System.out.println("Element at index 3: "

                           + anArray[3]);

        System.out.println("Element at index 4: "

                           + anArray[4]);

        System.out.println("Element at index 5: "

                           + anArray[5]);

        System.out.println("Element at index 6: "

                           + anArray[6]);

        System.out.println("Element at index 7: "

                           + anArray[7]);

        System.out.println("Element at index 8: "

                           + anArray[8]);

        System.out.println("Element at index 9: "

                           + anArray[9]);

    }

}

Add a comment
Know the answer?
Add Answer to:
Design a Java program that asks the user to enter an integer number n and then...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT