This discussion is archived
3 Replies Latest reply: Dec 10, 2012 8:15 AM by 979025

# Arrays

Currently Being Moderated

import javax.swing.*;
public class MinMax
{
public static void main(String args[])
{
// Declare a named constant for array size here.

// Declare array here.

// Use this integer variable as your loop index.
int loopIndex;

// Use this variable to store the number input by user.
int value;

// String version of number input by user.
String valueString;

// Use these variables to store the minimim and maximum values.
int min, max;

// Use these variables to store the total and the average.
double total, average;

// Write a loop to get values from user and assign to array.

valueString = JOptionPane.showInputDialog("Enter a value: ");
value = Integer.parseInt(valueString);
// Assign value to array.

// Assign the first element in the array to be the minimum and the maximum.
min = numbers[0];
max = numbers[0];
// Start out your total with the value of the first element in the array.
total = numbers[0];

// Write a loop here to access array values starting with numbers[1].

// Within the loop test for minimum and maximum values.

// Also accumulate a total of all values.

// Calculate the average of the 10 values.

// Print the values stored in the numbers array.

// Print the maximum value, minimum value, and average.

System.exit(0);

}
}
• ###### 1. Re: Arrays
Currently Being Moderated
Welcome to the forum!
>
>
Volunteers are happy to help. But they aren't going to write the code for you. For each of those sections post what you have tried so far.
• ###### 2. Re: Arrays
Currently Being Moderated
You are welcome to forum.
This is very good task for starters in Java.
You can read Oracle Java documentation or books and then you can solve these problems.

Thanks
• ###### 3. Re: Arrays
Currently Being Moderated
If we answer your questions, you will never be able to learn how to be a good programmer. Give it a shot and come back and we can help you with where yo uare having difficulties. That or, honestly, drop the class and choose a different career. :) Not everyone is cut out to be a developer. If you have to force yourself to do it, it might not be for you.

#### Legend

• Correct Answers - 10 points