Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I currently have code that simulates an American football game. I am looking to make its score randomized using a normal distribution curve from 0-60.

I currently have code that simulates an American football game. I am looking to make its score randomized using a normal distribution curve from 0-60. I am also looking to have it generate a first half score and then build on that to then show a finalized end game score. Here is the code I have so far

#include #include #include

using namespace std;

int main() { int home = 0; int away = 0; int total = 0; int winner = 0; int i; int j; int k; int l; int m; int n; int x; int y; int z; int a; int b; int c; int d; int e; int f; int g; int h; int overtime = 0;

default_random_engine engine; normal_distribution distribution(30.0,15.0);

for(i = 0; i < 2; i++) { for(j = 0; j < 15; j++) { total = ceil(distribution(engine)); if(i == 0) { home += total; } else { away += total; } } }

if(home == away) { overtime = 1; }

if(overtime == 1) { default_random_engine engine2; uniform_int_distribution distribution2(0,1); x = distribution2(engine2); if(x == 0) { default_random_engine engine3; uniform_int_distribution distribution3(3,7); y = distribution3(engine3); home += y; } else { default_random_engine engine4; uniform_int_distribution distribution4(3,7); z = distribution4(engine4); away += z; } }

if(home > away) { winner = 1; } else { winner = 2; }

if(overtime == 0) { cout << "Home: " << home << endl << "Away: " << away << endl; } if(overtime == 1) { cout << "Home: " << home << endl << "Away: " << away << endl << "Overtime" << endl; }

cout << "Winner: "; if(winner == 1) { cout << "Home"; } if(winner == 2) { cout << "Away"; }

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions