Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read list of numbers with readLine method in java?
    text
    copied!<p>I want ask a question about <code>readLine()</code> method. My project is about reading numbers in a <code>list</code> with separated spaces and calculate the arithmetic mean remainder with discarding the lowest and biggest numbers. I try some way to read number but all of them were incorrect. How can I read numbers with <code>readLine()</code> method in java ?</p> <p>P.S : Program should be working with <code>acm</code> Libary(Console Program)</p> <pre><code>int [] inputArray ; ---&gt; will this be helpful to me ? </code></pre> <p>Thanks your help.</p> <hr> <pre><code>import java.text.DecimalFormat; import java.util.Scanner; import acm.program.ConsoleProgram; public class CCC extends ConsoleProgram { public static void main(String[] args) { /* * For data input. */ Scanner kb = new Scanner(System.in); /* * Declare an array to store the judge's scores. */ double[] scores = new double[8]; /* * Declare variables for lowest and highest scores. */ double lowestScore = Integer.MAX_VALUE; double highestScore = Integer.MIN_VALUE; /* * Read 7 judge's scores. */ for (int i = 0; i &lt; 7; i++) { System.out.println(String.format("Judge Score #%d: ", i + 1)); scores[i] = kb.nextDouble(); /* * Compare the current score with the lowest and the highest scores. */ if (scores[i] &lt; lowestScore) { lowestScore = scores[i]; } if (scores[i] &gt; highestScore) { highestScore = scores[i]; } } /* * Sum the scores, except the lowest and the highest scores. */ double total = 0.00; for (int i = 0; i &lt; 7; i++) { if (scores[i] != lowestScore &amp;&amp; scores[i] != highestScore) { total = total + scores[i]; } } /* * Display the output. */ DecimalFormat df = new DecimalFormat("0.00"); System.out.println("Total points received: " + df.format(total)); System.out.println("Arithmetic Mean : " + df.format(total / 7)); } </code></pre> <p>}</p> <hr> <p>This is my code ,ı asked stackedoverflow's people how to solve the problem but i couldn't solve it .In this program , i should get the number list from the user.For example; user writes a list " 11 23 4 55 66 7"(there are spaces between the numbers).My program should discard the biggest and lowest numbers to calculate the arithmetic mean.I do it with scanner method succesfully,as you can see but the teacher wants me to write this program with ACM libary(consoleprogram).This program runs like Java Application successfully but when i want to run it in Java Applet,i can't do it.</p> <p>Thanks for your help and understanding.</p> <hr> <p>Are there anyone to help me ?</p>
 

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