Rank: Veteran Joined: 2/3/2010 Posts: 1,797 Location: Kenya
|
Seq Lu wrote:holycow wrote: Total votes cast = XHalf of X = x/2= YUhurus votes = Utherefore, if U-Y is greater 1, no runoff, elseif U-Y is less than 1 or -ve, runoff. Where X, Y and U are variables depending on IEBC figures. a quick API to help wazua calculate this package org.iebc.prezzo.votes;
import java.util.Scanner;
/** * @author xxxx yyyy * */ public class WinnerCalculator {
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub
/* * @non-javaDocs * Prompt user to enter totalVotesCast, * 2d prompt - UhuruVotes */ Scanner scan = new Scanner(System.in); System.out.println("Enter total Votes Cast: "); int totalCast = scan.nextInt(); System.out.println("Enter Uhuru votes: "); int uhuruVotes = scan.nextInt();
// This sh*t returns true if second roundi :) System.out.println("Is Second round? : " + isSeccondRound(totalCast, uhuruVotes)); // test data // isSeccondRound(10115704, 3115704) }
/** * evaluate if runoff * * @param totalVotesCast (not null) * @param uhuruVotes (not null) * * @return isSecondRound - true or false */ public static boolean isSeccondRound(int totalVotesCast, int uhuruVotes) {
int fifty_Percent_Plus_One = 0;
fifty_Percent_Plus_One = totalVotesCast / 2; int _holder = uhuruVotes - fifty_Percent_Plus_One;
// conditional if return (_holder < 1 ? true : false); // runoff if true else nope } } Out put with sample dataEnter total Votes Cast: 10115704 Enter Uhuru votes: 6115704 Is Second round? : false ara? uk at 6m  ama ni hackers  I may be wrong..but then I could be right
|