This question has been answered by someone else before but was not complete so kindly this time answer this in full and also when you write classes do send the code as well with the answer.
Question:
You will be tasked to write this program in Java.
The goal is for the program to be able to guess the user's political party before they reach the end of the survey. This will require your program to gather a substantial amount of data before it can make accurate guesses. In particular:
TASK:
The last question should ask which political party they affiliate with. This way you will be able to gather and store data corresponding to the results you acquire. Create at least 4 political party storage.
import java.util.Arrays;
import java.util.function.Function;
public class PredictPoliticalParty implements Function<Double[], Double> {
int voterList;
int voteForPartyA,voteForPartyB,voteForPartyC,voteForPartyD,acquiredVote,castedVote;
public PredictPoliticalParty(int voterList, int voteForPartyA, int voteForPartyB, int voteForPartyC,
int voteForPartyD, int acquiredVote, int castedVote) {
super();
this.voterList = voterList;
this.voteForPartyA = voteForPartyA;
this.voteForPartyB = voteForPartyB;
this.voteForPartyC = voteForPartyC;
this.voteForPartyD = voteForPartyD;
this.acquiredVote = acquiredVote;
this.castedVote = castedVote;
}
public int castedvote(int party){
if((voteForPartyA/castedVote)>(voteForPartyB/castedVote)){
System.out.println("Candidate belongs to party A");
}else if((voteForPartyB/castedVote)>(voteForPartyC/castedVote)){
System.out.println("Candidate belongs to party B");
}else if((voteForPartyC/castedVote)>(voteForPartyD/castedVote)){
System.out.println("Candidate belongs to party C");
}else{
System.out.println("Candidate belongs to party D");
}
return party;
}
@Override
public Double apply(Double[] t) {
// TODO Auto-generated method stub
return null;
}
}
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
PredictPoliticalParty pp=new PredictPoliticalParty(32222222, 2345, 3432, 455666, 4455, 333, 333);
pp.castedvote(3990);
}
}
Output:
Comments
Leave a comment