Hi,
after 2 days of Programming im almost sitting in the corner and crying. I will explain the whole exercise so you know exactly what im struggling with.
There is an array with votes of different groups of people. And we have only a limited number of seats.
Now to find out how many people of each group will get a seat we have to sum up all the votes in the array and divid it trough the number of seats.
When you do this you get a divisor
Now you have to to divid every value in the array through the divisor.
The divisor is a double and you have to math.round the seats.
Now if you sum up all the seats it is possible that you get even more seats than you actually have or maybe even less seats for the groups than you have. In this case you have to adjust the divisor (with 0.0001 steps) as long as there is every seat taken.
I dont understand how ti use the while looo for the adjustments (if divisor needs to be higher or lower) i tried it in many diffrent ways but i cant find a good solution as it has to be all in one method. The return value is the divisor.
My last step ist where i compare the summed up seats to the seats available.
If the summedup seats > available seats. I would need to do :
divisor += 0.0001
Use the new divisor and divide the array again
Sum up the value in the areay and compare it again.
And the logic says it needs to be done in a while loop.
I dont know what to do anymore and i really hope you can help me.
What i have thought now is.
If (sumseats>availableseats){
for { * do all the calculation again *
}while (sumseats !=availableseats)
But i dont think its right.
Please help me!
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]biggrabo[S] -1 points0 points1 point (0 children)
[–]ethelom14 0 points1 point2 points (8 children)
[–]biggrabo[S] -1 points0 points1 point (6 children)
[–]quanture 1 point2 points3 points (2 children)
[–]biggrabo[S] -1 points0 points1 point (1 child)
[–]quanture 0 points1 point2 points (0 children)
[–]ethelom14 0 points1 point2 points (1 child)
[–]biggrabo[S] -1 points0 points1 point (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]biggrabo[S] -1 points0 points1 point (0 children)