Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in C++ which is to simulate a software that will be used to inst

ID: 3823909 • Letter: W

Question

Write a program in C++ which is to simulate a software that will be used to instantly check or report on the truthfulness of politicians. The way it will work is that whenever a politician declares anything (maybe in a debate), that statement will be processed and determined as a) HONEST, b) LIE, c) MISLEADING. Your simulation should have 2 politicians P0 and P1 who take turns making statements and follow ups. Use a random number generator to generate integers which are to represent the truthfulness of a particular statement. If the number is less than 33 it is a lie, less than 66 but more than or equal to 33 it is misleading. And equal to or more than 66 it is honest. P0 has a uniform distribution 1 to 100 and P1 has a normal distribution with mean =60 standard deviation = 10. Generate 100 statements for each and then print the percentage over all scores for both P0 and P1. e.g. P1 40% 33% etc...

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <random>
#include <cmath>
using namespace std;
void normalDist()
{
float honest=0;
float lie=0;
float mL=0;
int total=0;
std::random_device rd;
std::mt19937 gen(rd());// inbuilt function
std::normal_distribution<> d(60,10);//d(mean,Medain)

std::map<int, int> hist;
for(int n=0; n<100; ++n) {
++hist[std::round(d(gen))];
}
for(auto p : hist) {
total++;
int x= p.first ;
if(x<33)
lie++;
else if(x>=33 && x<66)
mL++;
else if(x>=66)
honest++;

  
}
cout<<" "<<"P1"<<" a)" << (honest*100)/total<<"% "<<" b) " << (lie*100)/total<<"% "<<" C) "<<(mL*100)/total<<"% ";
}
void uniformDistribution()
{
int honest=0;
int lie=0;
int mL=0;
std::random_device rd; //Will be used to obtain a seed for the random number engine
std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
std::uniform_int_distribution<> dis(1, 100);//range max and min values

for (int n=0; n<100; ++n)
{
int p=dis(gen);
if(p<33)
lie++;
else if(p>=33 && p<66)
mL++;
else if(p>=66)
honest++;
}
cout<<" "<<"P0"<<" a)" << honest<<"% "<<" b) " << lie<<"% "<<" C) "<<mL<<"% ";

}

int main()
{
uniformDistribution();// Method to print uniform random percentages
normalDist();//method to print normal distribution percenatgess
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote