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

Question #232006
You will be tasked to write this program in either C++ or Java, whichever you feel more comfortable with.
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:

4. Some answers to questions correspond with more than one political party. Find a way to make your program advanced enough so that it can weigh answers with differing levels of intensity depending on which parties they correspond best with.
1
Expert's answer
2021-09-01T23:57:39-0400
#include <iostream>
using namespace std;
int main(){
	int choice1, choice2;
	int repParty =0, demParty=0, indParty=0, greenParty=0 ; //Representing political affiliations
	cout << "What should the tax rate be?" << endl;


cout << "1 = Everyone to pay the same tax" << endl;


cout << "2= Wealthiest persons to pay more taxes)" << endl;


cout << "3 = I don't know" << endl;


cout << "4 = None " << endl;


cin >> choice1;


if (choice1 == 1) {




repParty++;}


if (choice1 == 2) {


demParty++; }


if (choice1 == 3){


indParty++;indParty++;


repParty++;}


if (choice1 == 4) {


greenParty++;greenParty++;


demParty++;
}
cout<<"b. What  government to uplift poverty?\n"<<endl;
cout<<"1=Equal distribution of resources.\n";
cout<<"2=Investing more funds in schools.\n";
cout<<"3=Incentivize welfare.\n";
cout<<"4= Nothing\n";
cin>>choice2;
if (choice2 == 1) {




repParty++;}


if (choice2 == 2) {


demParty++; }


if (choice2 == 3){


indParty++;indParty++;


repParty++;}


if (choice2 == 4) {


greenParty++;greenParty++;


demParty++;
}




int arr[4] = {repParty,demParty,indParty,greenParty};
int max =arr[0], index=0;
for(int i=0; i<4; i++){
	if(arr[i]>max){
		max = arr[i];
		index  = i;
	}
	
}
string arr1[4] = {"rep","dem","ind","green"};
cout<<"The closest political party is \t"<<arr1[index]<<endl;
}

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