Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to write my Java program with the ACM library (ConsoleProgram)?
    primarykey
    data
    text
    <p>I want ask a little question about my program.</p> <p>This is my code sample:</p> <pre><code>public static void main(String[] args) { int q; int p; int thelargest; int thesmallest; Scanner input = new Scanner(System.in); System.out.println("Enter the list of number : "); String input2 = input.nextLine(); String[] numbers = input2.split(" "); int[] result = new int[numbers.length]; for (p = 0; p &lt; numbers.length; p++) { result[p] = Integer.parseInt(numbers[p]); } for (q = 0; q &lt; result.length; q++) { System.out.print(""); System.out.println(result[q]); } System.out.println("Largest Number : " + LargestNumber(result)); System.out.println(" Smallest Number : " + SmallestNumber(result)); thelargest = LargestNumber(result); thesmallest = SmallestNumber(result); System.out.println("The Arithmetic Mean : " + AirthmeticMean(result, thesmallest, thelargest)); } public static int SmallestNumber(int[] series) { int thesmallest = series[0]; for (int i = 1; i &lt; series.length; i++) { if (series[i] &lt; thesmallest) { thesmallest = series[i]; } } return thesmallest; } public static int LargestNumber(int[] series) { int thelargest = series[0]; for (int i = 1; i &lt; series.length; i++) { if (series[i] &gt; thelargest) { thelargest = series[i]; } } return thelargest; } public static float AirthmeticMean(int[] result, int thesmallest, int thelargest) { int sum = 0; for (int i = 0; i &lt; result.length; i++) { sum += result[i]; } sum -= thesmallest; sum -= thelargest; return (float) sum / result.length; } </code></pre> <p>How can I convert this code sample to the ConsoleProgram (which is in the ACM library)? Which parts must I change or add?</p> <p>I started with:</p> <pre><code>public class ArithmeticMean extends ConsoleProgram { } </code></pre> <p>But I do not know what to do next.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload