Questions
Complete the following task in C++. Separate your class into header and cpp files. You can...

Complete the following task in C++. Separate your class into header and cpp files. You can only useiostream, string and sstream. Create a main.cpp file to test your code thoroughly.

Given : commodity.h and commodity.cpp here -> https://www.chegg.com/homework-help/questions-and-answers/31-commodity-request-presented-two-diagrams-depicting-commodity-request-classes-form-basic-q39578118?trackid=uF_YZqoK

Create :

locomotive.h, locomotive.cpp, main.cpp

Locomotive Class Hierarchy

Presented here will be a class diagram depicting the nature of the class hierarchy formed

between a parent locomotive class and its children, the two kinds of specic trains

operated. The relationship is a strict one to many relationship with each specic class of

locomotive being a direct descendent of the locomotive class. The inheritance type is

public in all cases.

The locomotive class is the parent class which the other 2 are descended

from DieselElectric and Steam . In particular it is also an abstract class, having a pure virtual function and is not

intended to be instantiated. Note that only salient features are captured in the above

class diagram. For full specics on each of the classes, refer below. The class specics

of the subclasses are discussed below with a UML specication and details about what

specic behaviour, functions and operators each class needs to implement.

3.2.1 Locomotive Parent Class

locomotive

-name:string

-topSpeed:double

-maxCars:int

-tonLimit:int

-cars:commodity**

---------------------------

+locomotive()

+locomotive(name:string, topSpeed:double ,maxCars:int,tonLimit:int)

+getName() const:string

+setName(s:string):void

+getTopSpeed() const:double

+getMaxCars() const:int

+getTonLimit() const:int

+setTopSpeed(s:double):void

+setMaxCars(s:int):void

+setTonLimits(s:int):void

+getCurrentTopSpeed():double

+printManifest():void

+addCar(c:commodity*):int

+removeCar(s:string):int

+unassignCars():void

+getFirstCar():commodity *

+getCurrentTons():int

+getCurrentCars():int

+~locomotive()

+generateID()=0:string

+calculateRange():double

+getType():string

The variables are as follows:

name: The name of the locomotive. This is unique.

topSpeed: The maximum speed the locomotive can do unlimbered by any cars in

km.

maxCars: The total number of cars the locomotive can pull safely.

tonLimit: The number of tons the locomotive can carry in total across all of its

cars.

cars: The list of cars it pulls, each carrying one kind of specic commodity.

The functions are as follows:

locomotive(): The default constructor which should be empty.

The setMaxCars setter should initialise the memory of the cars variable if it has not

been set by that point.

locomotive(name:string , topSpeed:double ,maxCars:int,tonLimit:int ): The value

constructor for the class. It should allocate memory for the cars variable but leave

it unlled with nulls.

locomotive: This is the default destructor for the class. It is virtual.

generateID: This is a pure virtual function in this class. It will generate a unique

and specic id for each train class. See the specic classes for more detail on creating

it.

getter and setter: Each of the variables of the class has a getter and a setter assigned

to it that simply returns or overwrites the variable's value.

getType: This function returns the type of the locomotive as a string. The base

class type should be set to locomotive. It is virtual and the children should override

it to return dieselElectric and steam respectively.

getCurrentTons(): This function calculates the current number of tons being carried

by the locomotive and returns it.

getFirstCar(): This function returns the rst car held by the train.

getCurrentCars(): This function returns the current number of cars attached to the

train.

getCurrentTopSpeed(): This function calculates and returns the current top speed

potential for the train based on the load it is carrying. The new speed is calculated

based on the following equation:

newSpeed = oldSpeed - (1,7 * numberOfPulledCars) - (1,01*(pulledTons/10.0)

Do not use the maximums of either the pulled tons or number of cars, you need to

determine how many cars and tons the train is actually carrying to factor in the

correct speed. Additionally, if the train is overburdened, that is carrying more than

it can actually pull so it has a negative speed, the returned speed is 0.

printManifest():This function prints out the contents of the train's cars in the fol-

lowing format (assuming 2 cars for an example):

Train: Blue Jay

Car 1: Iron Ore

Car 2: Unprocessed Lumber

Total Tons: 300

The train's name is printed first, followed by the commodity in each of the cars.

The final ton total is calculated as well. Put your new lines at the end of each line.

calculateRange(): This virtual function calculates the actual eective range of the

train in terms of how far it can go on a single load of fuel. Each train uses a

dierent method of fuel storage so see each separate subclass for more information.

By default, this should be return 0.

addCar(c:commodity*): This adds a car at the rst open space in the cars array. It

returns the index of the addition. If it is not possible to add it, the function returns

-1. Cars cannot be added if they would otherwise violate the ton or car limits.

removeCar(s:string): This removes (deallocates the memory) a car with the id

passed in. It returns with the index of the car that was removed. If it is not

possible to add it, the function returns -1.

unassignCars(): This removes all cars (deallocates the memory) of all cars in the

locomotive.

In: Computer Science

#18 Events A and B are mutually exclusive. Suppose event occurs with probability 0.05 and event...

#18


Events A and B are mutually exclusive. Suppose event occurs with probability 0.05 and event occurs with probability 0.36. a. Compute the probability that B occurs or does not occur (or both). b. Compute the probability that either occurs without occurring or occurs without occurring. (If necessary, consult a list of formulas.) ?


#19

Events and are mutually exclusive . Suppose event occurs with probability 0.11 and event B occurs with probability 0.81. If does not occur, what is the probability that occurs? Round your answer to at least two decimal places . (If necessary , consult a list of formulas .)

#20

Events A and are independent. Suppose event A occurs with probability 0.12 and event B occurs with probability 0.27. a. If event A or event occurs, what is the probability that B occurs? b. If does not occur, what is the probability that occurs? Round your answers to at least two decimal places. (If necessary, consult a lis of formulas.)

#21

Events A and B are independent . Suppose event A occurs with probability 0.69 and event occurs with probability 0.75. a . Compute the probability that A occurs but does not occur . b. Compute the probability that either occurs without occurring or and B both occur. ( If necessary , consult a list of formulas .) ?


Events A and are mutually exclusive. Suppose event A occurs with probability 0.05 and event B occurs with probability 0.36.

a. Compute the probability that occurs or A does not occur (or both).

b. Compute the probability that either A occurs without Boccurring or occurs without occurring. (If necessary, consult a list of formulas.) ?

this is hope the question is asked

In: Statistics and Probability

2. A clinical trial is conducted to evaluate the efficacy of a new drug for prevention...

2. A clinical trial is conducted to evaluate the efficacy of a new drug for prevention of hypertension in patients with pre-hypertension (defined as systolic blood pressure between 120–139 mmHg or diastolic blood pressure between 80–89 mmHg). A total of 20 patients are randomized to receive the new drug or a currently available drug for treatment of high blood pressure. Participants are followed for up to 12 months, and time to progression to hypertension is measured. The experiences of participants in each arm of the trial are shown below.

New Drug

Currently Available Drug

Hypertension

Free of Hypertension

Hypertension

Free of Hypertension

7

8

6

8

8

8

7

9

10

8

9

11

9

10

11

11

11

12

12

12

Estimate the survival (time to progression to hypertension) functions for each treatment group using the Kaplan-Meier approach.

New Drug

Complete the table below.

Time, Months

Number at Risk

Nt

Number of Events (Hypertension)

Dt

Number Censored

Ct

Survival Probability

St+1 = St*((Nt-Dt)/Nt)

0

10

7

8

9

10

11

12

Currently Available Drug

Complete the table below.

Time, Weeks

Number at Risk

Nt

Number of Events (Hypertension)

Dt

Number Censored

Ct

Survival Probability

St+1 = St*((Nt-Dt)/Nt)

0

10

6

7

8

9

10

11

12

To answer the question as to whether or not there is a difference in time to progression, a Chi square statistic is computed. The critical value for rejection of the null hypothesis is 3.84. The computed Chi square is 0.335.

Based on comparing the computed Chi square and the critical Chi square, which of the following is (are) true?

  1. There is not statistically significant evidence to show that the time to progression is different between groups.
  2. There is statistically significant evidence to show that the time to progression is different between groups.
  3. The time to progression is essentially the same for each group.
  4. a and c.

The hazard ratio risk of progression to hypertension is 0.658. Based on this computation, which of the following is (are) true?

  1. The risk of progression to hypertension is reduced by 34.2% in patients assigned to the new drug as compared to the currently available drug.
  2. The risk of progression to hypertension is 1.52 times higher in patient’s current drug as compared to the new drug.
  3. The risk of progression to hypertension is 5.12 times higher in patient’s current drug as compared to the new drug
  4. a and b

In: Statistics and Probability

e. What is the probability that the card is a well shuffled deck of 52 cards....

e. What is the probability that the card is a well shuffled deck of 52 cards.

a. What is the probability that the card is a red card

b.What is the probability that the card is a face cards

c. What is the probability that the card is a queen or a club

d. What is the probability that the card is a heart or a face card

e. What is the probability that the card is a ace or a club card

d. What is the probability that the card is

In: Statistics and Probability

The last political survey that was carried out in the United States indicates that, of the...

The last political survey that was carried out in the United States indicates that, of the two randomly chosen citizens, the probability that they are liberal is .30, the probability that they are conservative are .55, and the probability that they are neither, is 0.15. The group of 10 Americans are chosen at random.

What is the probability that four are liberal?

What is the probability that neither is conservative?

What is the probability that two are neither?

What is the probability that at least eight are liberals?

In: Statistics and Probability

The last political survey that was carried out in the United States indicates that, of the...

The last political survey that was carried out in the United States indicates that, of the two randomly chosen citizens, the probability that they are liberal is .30, the probability that they are conservative are .55, and the probability that they are neither, is 0.15. The group of 10 Americans are chosen at random.

What is the probability that four are liberal?

What is the probability that neither is conservative?

What is the probability that two are neither?

What is the probability that at least eight are liberals?

In: Statistics and Probability

The world is currently being adversely affected by the COFLU-20 pandemic. Persons are required to take...

The world is currently being adversely affected by the COFLU-20 pandemic. Persons are required to take certain measures to prevent the spread of this virus; however, persons’ knowledge, attitudes and practices towards COFLU-20 may influence their adherence to these measures.

A researcher decided to evaluate the knowledge, attitudes and practices towards COFLU-20 of adults living in the English-speaking Caribbean. To gather the data, the researcher developed an online survey consisting of four (4) sections. Section A gathered demographic data on the respondents including their gender, marital status, highest level of education attained, occupation and country of residence. Section B consisted of 15 questions that gathered data on the respondents’ knowledge of COFLU-20. Section C consisted of 10 questions that gathered data on the respondents’ attitudes towards COFLU-20. The final section, Section D, consisted of 5 questions that gathered information on the respondents’ practices against COFLU-20.

In order to recruit respondents for this survey, the researcher sent a link to the online survey to persons in his network via email and social media. After receiving 300 responses, the researcher closed down the online survey and deactivated the link to the survey.

You are a student pursuing an introductory Statistics course. The researcher has asked that you assist him in summarizing, analyzing and interpreting the information gathered, by answering the questions below.

QUESTION 1

((

(a) (i)   Identify the population of interest for this scenario.                                        [1 mark]

(ii) Identify the sampling technique used by the researcher.                                   [1 mark]

(iii) State one advantage and one disadvantage of the sampling technique described in the given scenario.                                                                                                          [2 marks]

Table below summaries the age group of the 300 respondents.

Table 1

Age Group

Number of Respondents

18-25

62

26-34

60

35-44

55

45-54

70

55 - 75

53

(b) Use the data given in Table 1 to:

continue overleaf…/

(i) calculate the mean age of the respondents                                                   [3 marks]

(ii) identify the modal interval and interpret your answer                                [2 marks]

(iii) identify the median interval                                                                      [1 mark]

Each respondent was given a score, from 1 to 15, on his or her knowledge of the COFLU-20. A score from 1 to 7 was considered to indicate ‘poor’ knowledge, 8 to 11 indicated ‘satisfactory’ knowledge and 12 to 15 indicated good knowledge. Table 2 below shows the knowledge level of respondents, by age group.

Table 2

Age Group

Knowledge Level

Total

Poor

Satisfactory

Good

18 - 25

33

16

13

62

26 - 34

30

18

12

60

35 - 44

29

14

12

55

45 - 54

36

16

18

70

55 - 75

17

14

22

53

Total

145

78

77

300

(c) Using Table 2, assist the researcher to calculate the probability that a randomly selected respondent:

(i) is below 35 years of age and has good knowledge of the COFLU-20          [2 marks]

(ii) is below 35 years of age or has good knowledge of the COFLU-20            [3 marks]

Total 15 marks

QUESTION 2

To examine practices towards COFLU-20, the researcher examined the relevant responses from the survey and assigned scores of 1 (below required standard), 2 (poor standards), 3 (satisfactory standards), 4 (meets required standards) and 5 (exceeds required standard) to each respondent. Using X to represent the score for practices against COFLU-20, the probability distribution of X is shown in Table 3 below.

Table 3

x

1

2

3

4

5

P(X =x)

0.21

0.197

0.2

0.173

0.22

continue overleaf…/

The researcher is interested in using the information in Table 3 to determine the probability that, from a sample of 10 randomly selected adults, exactly 3 of them exceeds the required standard for practices towards COFLU-20.

(a) Assist the researcher by:

(i) carefully defining the random variable of interest                                          [1 mark]

                       

(ii) identifying a suitable probability distribution to be used to find the probability that exactly three (3) adults, out of 10, exceeds the required standard for practices towards COFLU-20. State the value(s) of the parameter(s) for this distribution.                                     [3 marks]

(iii) justifying the suitability of the probability distribution identified in part (ii)                                                                                                                                               [4 marks]

(iv) calculating the probability that exactly 3 adults, out of 10, exceeds the required standard for practices against COFLU-20                                                                                   [2 marks]

(b) Individual scores for practices towards COFLU-20 are found to be normally distributed with a mean of 3 and a standard deviation of 1.5 over the entire population. The Ministry of Health wishes to use this information to identify individuals whose score on practices towards COFLU-20 is in the lower 75%, in order to give them relevant information on the best practices towards COFLU-20. You are asked to assist in calculating the score that the Ministry of Health should use to decide whether an individual should be given the relevant information?       [5 marks]

Total 15 marks

In: Statistics and Probability

The National Football League (NFL) records a variety of performance data for individuals and teams. To...

The National Football League (NFL) records a variety of performance data for individuals and teams. To investigate the importance of passing on the percentage of games won by a team, the data shown presents the average number of passing yards per attempt (Yds/Att) and the percentage of games won (WinPct) for a random sample of 10 NFL teams for the 2011 season (NFL website, February 12, 2012).

Team Yds/Att Win%
Arizona Cardinals 6.5 50
Atlanta Falcons 7.1 63
Carolina Panthers 7.4 38
Chicago Bears 6.4 50
Dallas Cowboys 7.4 50
New England Patriots 8.3 81
Philadelphia Eagles 7.4 50
Seattle Seahawks 6.1 44
St. Louis Rams 5.2 13
Tampa Bay Buccaneers 6.2 25

Perform the following:

1.)Develop a scatter diagram with the number of passing yards per attempt on the horizontal axis. What does the scatter diagram indicate about the relationship between the two variables?
2.)What is the estimated regression equation (use 2 decimal places)?
3.)Conclude on the goodness of fit.
4.)Test if the independent variable is significant. Use a = 0.10 and make sure to show all 5 steps in your test.
5.)Test the equation as a whole. Use a = 0.10 and make sure to show all 5 steps in your test.
6.)Do the assumptions about the error term seem reasonable? Use the appropriate statistical tool.
7.)Interpret the coefficient of the independent variable
8.)Develop a 90% confidence interval estimate of the mean win percentage if the passing yards per attempt is 6.2.
9.)Develop a 90% prediction interval for the Kansas City Chiefs who had an average passing yards per attempt of 6.2 for the season. .
10.)Compare your results in part i. when the known record for the KC Chiefs for the 2011 season was 7 wins and 9 losses.

In: Statistics and Probability

A study identified top accounting firms across the United States. The Southeast and Gulf Coast regions...

A study identified top accounting firms across the United States. The Southeast and Gulf Coast regions reported the highest combined growths. A characteristic description of the accounting firms in the Southeast and Gulf Coast regions included the number of partners in the firm. Below represents the number of partners within various firms of the two regions [Southeast and Gulf Coast].

Southeast     174          Gulf Coast     79
Southeast     45            Gulf Coast     106
Southeast     29            Gulf Coast     22
Southeast     51            Gulf Coast     22
Southeast     40            Gulf Coast     38
Southeast     10            Gulf Coast     17
Southeast     29            Gulf Coast     27
Southeast     37            Gulf Coast     21
Southeast     32            Gulf Coast     17
Southeast     22            Gulf Coast     12
Southeast     9              Gulf Coast     9
Southeast     30            Gulf Coast     6
Southeast     21            Gulf Coast     9
                                       Gulf Coast     12
                                       Gulf Coast     18

(a)At the 0.05 level of significance, is there evidence of a difference in the variability in numbers of partners for Southeast region accounting firms and Gulf Coast accounting firms? (Include: null and alternate hypotheses, value of test statistic, decision rule, conclusion in a complete sentence that includes why in terms of the decision rule.)

(b) Interpret the p-value.

(c) What assumption do you have to make about the two populations in order to justify the use of the F test?

(d) Based on (a) and (b), which t test [Pooled Variance t-test or Separate Variance t-Test] should you use to test whether there is a significant difference in the mean number of partners for Southeast region accounting firms and Gulf Coast accounting firms?

In: Statistics and Probability

Create a c++ program that: Create an input file using notepad ( .txt ). When testing...

Create a c++ program that:

  1. Create an input file using notepad ( .txt ). When testing your program using different input files, you must change the filename inside your program otherwise there will be syntax errors.
  2. There are a finite number of lines to be read from the data file. But we can’t assume to know how many before the program executes; so, the standard tactic is to keep reading until you find the “End of File” marker.
  3. Input date file consists of scores (one per line), might contain no score at all (an empty file) and program does not know how many scores before execution.
  4. If file not empty, determine how many valid scores (0 to 100), and how many invalid scores (less than 0 or greater than 100).
  5. Take only the valid scores and determine what letter grade and keep track of how many As, Bs, Cs, Ds, and Fs.  

(90 to 100 is an A, 80 to 89 is a B, 70 to 79 is a C, 60 to 69 is a D, 0 to 60 is a F)

  1. Output to the screen (not file output) with the followings: the number of valid scores, the number of invalid scores, the highest valid score, the lowest valid score, and the average of the valid scores. Also print out the histogram of the grades (sideway). Look at my output examples
  2. If the file is empty, don’t print any statistics at all. If the input file only has invalid scores, just print how many invalid scores and no valid scores, don’t include any statistics.
  3. Test your program with difference cases/scenarios.

In: Computer Science