我不知道如何从投票中输出抽奖任何帮助,我们将不胜感激。
目前,它将允许用户选择候选人数量,然后用户输入详细信息。然后,用户将输入投票,即候选编号,并键入999以完成。输出将是获胜者或获胜者(抽奖)具有详细信息和投票的候选人以及不在开始时宣布的范围内的投票数量。
int x;
char highestChar = '1';
char nextHighestChar = '1';
String alpha = "123456";
int largest=intVoteCount[1];
int nextLargest=intVoteCount[1];
for( x=1; x<=range; x++){
if(intVoteCount[x]>largest){
largest = intVoteCount[x];
highestChar = alpha.charAt(intLoopCount);
}
if(intVoteCount[x]>highestChar){
nextLargest = intVoteCount[x];
nextHighestChar = alpha.charAt(intLoopCount);
}
}
System.out.println("The winner is Candidate number "+ highestChar + " with " + largest + " votes.");
System.out.println("The winner is Candidate number "+ nextHighestChar + " with " + nextLargest + " votes.");
System.out.println("-----------------------------");
System.out.println("The Candidate votes are as follows.");
for (intLoopCount = 1; intLoopCount <= range; intLoopCount++) {
// Display all records.
// New Instance
System.out.println("");
System.out.println("Candidate " + intLoopCount + " "
+ strCandidateTitle[intLoopCount] + " "
+ strCandidateFirstname[intLoopCount] + " "
+ strCandidateSurname[intLoopCount] + " votes "
+ intVoteCount[intLoopCount]);
}
System.out.println("-----------------------------");
System.out.println("Vote Count Spolit: " + intVoteCountSpolit);
}
}
答案 0 :(得分:0)
如果largest == nextLargest
你有平局,那么请打印出适当的消息说明;否则,你有一个明确的赢家。