Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In acm library no main method though you need to use instead the following construction:</p> <pre><code>public void run() {} </code></pre> <p>Here is an API of this library <a href="http://jtf.acm.org/javadoc/student/" rel="nofollow">http://jtf.acm.org/javadoc/student/</a> Select acm.program package ConsoleProgram class and find appropriate methods see also acm.io / class IOConsole</p> <p>e.g. System.out.println() --> println() Scanner (String input) --> readLine(String prompt) etc.</p> <p>the rest is the same as you in your code.</p> <p><strong>Ok, here you are your code in acm:</strong> (a bit ugly but works fine:)</p> <pre><code>import acm.program.ConsoleProgram; public class StackOverflow extends ConsoleProgram { private static final long serialVersionUID = 1L; public void run() { int q; int p; int thelargest; int thesmallest; String input2 = ""; String[] numbers = null; println("Enter the list of number : "); while (true) { String input = readLine(); if (input.equals("")) break; input2 += input + " "; } 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++) { print(""); println(result[q]); } println("Largest Number : " + LargestNumber(result)); println(" Smallest Number : " + SmallestNumber(result)); thelargest = LargestNumber(result); thesmallest = SmallestNumber(result); 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>And Run as JavaApplet</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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