Lotto counting Numbers& percentage Ideas/ Help
Hi guys,
Just curious on what ppl thought on methodolgy ...what ppl would suggest could be better.Thanks.
Anyway,I've just made a lottery program for fun which randomly 6 non duplicate numbers from a range of 0 - 49.These numbers get saved to a text file. I want to spice it up by it outputting the top numbers generated with a percentage showing written to next to each number, e.g. Out of 10000 numbers the 6 most pop numbers produced are: 6 = 15 %, 32 = 12%, 3 = 10%, 4 = 7% etc...
--
To achieve the first part above my intuitive way would be to firstly creating a 'while there is next element/string loop'
Each number is seperated by a space, so I would do a check for each number to see if the 2nd value is null, if it is then count the first string/int as the number. (or maybe next element method may recognise the space).
I will then make an int array storage with a space of 0-49.
Each int checked will create an incrementation (+1) to an array location corresponding to the value of int.It will also increment int count, which will be refered to later when finding the percentage of a number.
So basically the process is:
while(textfile.hasnextelement)
int value = Integer.parseInt(string);
array[value] = ++;
count ++;
Once the above has finished I should get an array storage index of 0-49 with so many values in each one with index number representing the individual value. Next I will do:
for(int i= 0; i < count; i++)
{
float percent = (count / index)*100;
//cut it down to 2 decimal points
index = percent;
}
Once the array is refilled with percentages. Each value is taken and stored in a int 'name' e.g, int one = index[1], etc to 49. After this the array can be sorted.
Then index[1] with a diffrent value can be referenced and compared to the value of the number name list e.g, index[1] has a value of 35 (percentage) which is int thirty. The top 6 comparisons can be printed with a referance to its number name (converted to string) with int percentage value.
Hope enjoyed reading. Open to ideas to improve/ tackle this before i still implementing.
Thanks
Message was edited by:
ra2or

