1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jeka94
3 years ago
7

In this case we will do automated testing against your program. In order to do this you will prompt (ask for input) for a random

seed and use it to seed your random number generator. This will allow you to test your program against several seeds. And we will test your program with a series of these random seeds. And this will not be your entire grade, but your ability to pass these tests is a part of your grade. This is a common industry practice and one we will try to introduce you.
Engineering
1 answer:
tester [92]3 years ago
8 0

Answer:

C++ code is given below with appropriate comments

Explanation:

#include<iostream>

#include<cstdlib>

using namespace std;

// takes in the horses int array and its size

// for each horse perform a toss

void toss(int horses[],int horse_count){

               

               for(int i=0; i<horse_count;i++){

                               // if the toss result is 1 we advance the horse

                               // if the result is zero we dont advance                  

                               bool advance= rand()%2==1;

                               if(advance)horses[i]++;

               }

}

//takes in the horses int array and its size

// returns true if there is a winner

// else returns false

bool isWinner(int horses[], int horse_count){

               

               for(int i=0; i<horse_count;i++){

                               if(horses[i]>=15){

                                               cout<<"Horse "<<i<<" wins!"<<endl;      

                                               return true;

                               }

                               

               }

               return false;

}

// takes in the horses int array and its size

// prints the horses with the track

int print(int horses[], int horse_count){

               

               

               for(int i=0;i<horse_count;i++){

                               

                               for(int track=1; track<horses[i];track++)cout<<".";

                               cout<<i;

                               for(int track=horses[i]+1;track<=15;track++)cout<<".";

                               cout<<endl;      

               }

               

               cout<<endl;

               cout<<endl;

}

int main(){

               

               unsigned int seed;

               cout<<"Please enter a random seed: ";cin>>seed;

               srand(seed);

               

               const int HORSES_COUNT=5;

               // we have taken an int array

             // the numbers are all set to 1

            // if the toss turns 1 we increment the value for that horse by 1

            // we keep on incrementing until the number is 15

               int horses[HORSES_COUNT]{1};

               

               // repeat the loop until there is a winner

               while(!isWinner(horses,HORSES_COUNT)){

                               toss(horses,HORSES_COUNT);

                               print(horses,HORSES_COUNT);

               }

               

}

You might be interested in
Both portions of the rod ABC are made of an aluminum for whichE = 70 GPa. Knowing that the magnitude of P is 4 kN, determine(a)
san4es73 [151]

Explanation:

ΔL_{BC} = ΔL_{AB}

\frac{(Q - 4000)(0.5)}{3.14* 0.03 *0.03 *70*10^{9} }     (1)

= \frac{4000*0.4}{3.14*0.01*0.01*70*10^{9} }

Q = 32,800 N

now put this value in equation 1.

Deflection of B = \frac{(32800-4000)(0.5)}{3.14*0.03*0.03*70*10^{9} }

                       = 0.0728 mm

4 0
4 years ago
potential difference is the work done in moving a unit positive charge from one point to another in an electric field. State Tru
kow [346]

Answer:

True

Explanation:

Because the <u>Electric Magnetic Field</u> is the work done per unit charge where other forms of energy is tranferred to electrical energy

5 0
4 years ago
____________engineers build and test tools and machines, and they rely heavily on computer, math, and problem-solving skills.
Wittaler [7]

Answer:Mechanical Engineers

Explanation: Mechanical engineering is an engineering branch that combines engineering physics and mathematics principles with materials science to design, analyze, manufacture, and maintain mechanical systems. It is one of the oldest and broadest of the engineering branches.

8 0
3 years ago
Read 2 more answers
Air exits a compressor operating at steady-state, steady-flow conditions at 150 oC, 825 kPa, with a velocity of 10 m/s through a
ioda

Answer:

a) Qe = 0.01963 m^3 / s , mass flow rate m^ = 0.1334 kg/s

b) Inlet cross sectional area = Ai = 0.11217 m^2 , Qi = 0.11217 m^3 / s    

Explanation:

Given:-

- The compressor exit conditions are given as follows:

                  Pressure ( Pe ) = 825 KPa

                  Temperature ( Te ) = 150°C

                  Velocity ( Ve ) = 10 m/s

                  Diameter ( de ) = 5.0 cm

Solution:-

- Define inlet parameters:

                  Pressure = Pi = 100 KPa

                  Temperature = Ti = 20.0

                  Velocity = Vi = 1.0 m/s

                  Area = Ai

- From definition the volumetric flow rate at outlet ( Qe ) is determined by the following equation:

                   Qe = Ae*Ve

Where,

           Ae: The exit cross sectional area

                   Ae = π*de^2 / 4

Therefore,

                  Qe = Ve*π*de^2 / 4

                  Qe = 10*π*0.05^2 / 4

                  Qe = 0.01963 m^3 / s

 

- To determine the mass flow rate ( m^ ) through the compressor we need to determine the density of air at exit using exit conditions.

- We will assume air to be an ideal gas. Thus using the ideal gas state equation we have:

                   Pe / ρe = R*Te  

Where,

           Te: The absolute temperature at exit

           ρe: The density of air at exit

           R: the specific gas constant for air = 0.287 KJ /kg.K

             

                ρe = Pe / (R*Te)

                ρe = 825 / (0.287*( 273 + 150 ) )

                ρe = 6.79566 kg/m^3

- The mass flow rate ( m^ ) is given:

               m^ = ρe*Qe

                     = ( 6.79566 )*( 0.01963 )

                     = 0.1334 kg/s

- We will use the "continuity equation " for steady state flow inside the compressor i.e mass flow rate remains constant:

              m^ = ρe*Ae*Ve = ρi*Ai*Vi

- Density of air at inlet using inlet conditions. Again, using the ideal gas state equation:

               Pi / ρi = R*Ti  

Where,

           Ti: The absolute temperature at inlet

           ρi: The density of air at inlet

           R: the specific gas constant for air = 0.287 KJ /kg.K

             

                ρi = Pi / (R*Ti)

                ρi = 100 / (0.287*( 273 + 20 ) )

                ρi = 1.18918 kg/m^3

Using continuity expression:

               Ai = m^ / ρi*Vi

               Ai = 0.1334 / 1.18918*1

               Ai = 0.11217 m^2          

- From definition the volumetric flow rate at inlet ( Qi ) is determined by the following equation:

                   Qi = Ai*Vi

Where,

           Ai: The inlet cross sectional area

                  Qi = 0.11217*1

                  Qi = 0.11217 m^3 / s    

- The equations that will help us with required plots are:

Inlet cross section area ( Ai )

                Ai = m^ / ρi*Vi  

                Ai = 0.1334 / 1.18918*Vi

                Ai ( V ) = 0.11217 / Vi   .... Eq 1

Inlet flow rate ( Qi ):

                Qi = 0.11217 m^3 / s ... constant  Eq 2

               

6 0
3 years ago
Two stepped bar is supported at both ends.At the join point of two segments,the force F is applied(downwards).Calculate reactive
nlexa [21]

Answer:

F=200kN

Explanation:

8 0
3 years ago
Other questions:
  • Two reversible cycles operate between hot and cold reservoirs at temperature TH and TC, respectively. If one is a power cycle an
    8·1 answer
  • Initialize the tuple team_names with the strings 'Rockets', 'Raptors', 'Warriors', and 'Celtics' (The top-4 2018 NBA teams at th
    5·1 answer
  • Tin atoms are introduced into a FCC copper crystal, producing an alloy with a lattice pa- rameter of 3.7589 x 10-8 cm and a dens
    8·1 answer
  • Compare and contrast arch and beam bridges
    13·1 answer
  • What are the effects of applying an additional layer of insulation to a cylindrical pipe or a spherical shell?
    7·1 answer
  • A. Calculate the concentration of a toxic (Cout) that is added to a lake with an input concentration of 100 μg/l. The flow rate
    10·1 answer
  • An error was reported in a software program by a user. Before that error can be diagnosed and fixed
    5·2 answers
  • What is the best way to collaborate with your team when publishing Instagram Stories from Hootsuite?
    14·1 answer
  • Question 2
    10·1 answer
  • What year is gas powered cars expected stop being produced
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!