Hi, I just don't seem to grasp arrays at all! So am continuing my practice in java.
QUESTION:
It's a radio poll on the most listened to radio station.
I have to read the UNKNOWN number of integers from a file and output the percentage of all listeners that listen to each radio station.
Each station has a unique code 1-5.
It sounds pretty simple but not when I attempt to code it.
Here is what I did:
import java.util.*; import java.io.*; public class RadioStationsPoll{ public static void main (String [] args) throw IOException{ Scanner in = new Scanner (new FileReader("polls.txt")); int [] allStationCodes = new int []; int stationCode , i, total; int [] stationCount = new int []; stationCode = in.nextInt(); while (stationCode !=0) { for (int i = 1; i < 5; i++) { if (stationCode [i] == i) { stationCount[i] = (stationCode[i]) ++; } total = total + count [i]++; System.out.printf ("Station" + i + "%d percent" + stationCount [i] /total); i++; } } } }