Answer to Question #233504 in Java | JSP | JSF for Zia

Question #233504

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.


1
Expert's answer
2021-09-06T00:16:19-0400
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:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS