Questions
Task CPP Create a class called Mixed. Objects of type Mixed will store and manage rational...

Task CPP

Create a class called Mixed. Objects of type Mixed will store and manage rational numbers in a mixed number format (integer part and a fraction part). The class, along with the required operator overloads, should be written in the files mixed.h and mixed.cpp.

Details and Requirements

  1. Finish Lab 2 by creating a Mixed class definition with constructor functions and some methods.

  2. The Mixed class should have public member functions Evaluate(), ToFraction(), and Simplify(). The Evaluate() function should return a double, the others don’t return anything. These functions have no parameters. The names must match the ones here exactly. They should do the following:

    • Evaluate function should return the decimal equivalent of the mixed number.
    • Simplify function should simplify the mixed number representation to lowest terms. This means that the fraction part should be reduced to lowest terms, and the fraction part should not be an improper fraction (i.e. disregarding any negative signs, the numerator is smaller than the denominator).
    • ToFraction function should convert the mixed number into fraction form. (This means that the integer part is zero, and the fraction portion may be an improper fraction).
  3. Create an overload of the extraction operator >> for reading mixed numbers from an input stream. The input format for a Mixed number object will be:

    integer numerator/denominator

    i.e. the integer part, a space, and the fraction part (in numerator/denominator form), where the integer, numerator, and denominator parts are all of type int. You may assume that this will always be the format that is entered (i.e. your function does not have to handle entry of incorrect types that would violate this format). However, this function should check the values that come in. In the case of an incorrect entry, just set the Mixed object to represent the number 0, as a default. An incorrect entry occurs if a denominator value of 0 is entered, or if an improper placement of a negative sign is used. Valid entry of a negative number should follow this rule - if the integer part is non-zero, the negative sign is entered on the integer part; if the integer part is 0, the negative sign is entered on the numerator part (and therefore the negative sign should never be in the denominator). Examples:

    Valid inputs: 2 7/3 , -5 2/7 , 4 0/7 , 0 2/5 , 0 -8/3

    Invalid inputs: 2 4/0 , -2 -4/5 , 3 -6/3 , 0 2/-3

  4. Create an overload of the insertion operator << for output of Mixed numbers. This should output the mixed number in the same format as above, with the following exceptions: If the object represents a 0, then just display a 0. Otherwise: If the integer part is 0, do not display it. If the fraction part equals 0, do not display it. For negative numbers, the minus sign is always displayed to the left.

    Examples: 0 , 2 , -5 , 3/4 , -6/7 , -2 4/5 , 7 2/3

  5. Create overloads for all 6 of the comparison operators ( < , > , <= , >= , == , != ). Each of these operations should test two objects of type Mixed and return an indication of true or false. You are testing the Mixed numbers for order and/or equality based on the usual meaning of order and equality for numbers. (These functions should not do comparisons by converting the Mixed numbers to decimals – this could produce round-off errors and may not be completely accurate).
    • Hint: You can define most of the operation through a combination of == and <.
  6. Create operator overloads for the 4 standard arithmetic operations ( + , - , * , / ) , to perform addition, subtraction, multiplication, and division of two mixed numbers. Each of these operators will perform its task on two Mixed objects as operands and will return a Mixed object as a result - using the usual meaning of arithmetic operations on rational numbers. Also, each of these operators should return their result in simplified form. (e.g. return 3 2/3 instead of 3 10/15, for example).

    • Use function __gcd (you need to add #include <algorithm>) for calculation of the greatest common divisor) for simplification of the fractions. For subtraction and division, you can use inverse rules to simplify your code, see Inverse of rational number.

    • In the division operator, if the second operand is 0, this would yield an invalid result. Since we have to return something from the operator, return 0 as a default (even though there is no valid answer in this case). Example:

        Mixed m(1, 2, 3);  // value is 1 2/3
        Mixed z;           // value is 0
        Mixed r = m / z;   // r is 0 (even though this is not good math)
      
  7. Create overloads for the increment and decrement operators (++ and –). You need to handle both the pre- and post- forms (pre-increment, post-increment, pre-decrement, post-decrement). These operators should have their usual meaning – increment will add 1 to the Mixed value, decrement will subtract 1. Example:

     Mixed m1(1, 2, 3);             //  1 2/3
     Mixed m2(2, 1, 2);             //  2 1/2
     cout << m1++;                    //  prints 1 2/3, m1 is now 2 2/3
     cout << ++m1;                    //  prints 3 2/3, m1 is now 3 2/3
     cout << m2--;                    //  prints 2 1/2, m2 is now 1 1/2
     cout << --m2;                    //  prints 1/2  , m2 is now 0 1/2
    
  8. The Mixed class declaration is provided.

Driver Program

The sample driver program that is provided can be found below. Note, this is not a comprehensive set of tests. It is just some code to get you started, illustrating some sample calls.

#include <iostream>
#include "mixed.h"
using namespace std;

int main(){
Mixed m0(1, 1, 1); // 1 1/1 == 2
m0.Simplify();
cout << m0 << endl; // prints 2
m0.ToFraction();
cout << m0 << endl; // prints 2/1
Mixed m1(1, 2, 3);   // 1 2/3
m1.Print(); // prints 1 2/3
cout << m1++ << endl; // prints 1 2/3, m1 is now 2 2/3
cout << ++m1 << endl; // prints 3 2/3, m1 is now 3 2/3
Mixed m2(2, 5, 3);   // 2 5/3
cout << m2 << endl; // prints 2 5/3
cout << m2.Evaluate() << endl; // prints 3.6666
m2.Simplify(); // m2 is now 3 2/3
cout << m2 << endl; // prints 3 2/3
Mixed m3 = m1 + m2; // m3 is now 7 1/3
cout << m3 << endl; // prints 7 1/3
cout << m3.Evaluate() << endl; // prints 7.3333
Mixed m4(1, 2, 3);   // 1 2/3
m4.ToFraction();
cout << m4 << endl; // prints 5/3
Mixed m5 = m4 + Mixed(1);
cout << m5 << endl; // prints 2 2/3
Mixed m6(1);
cout << m6 << endl; // prints 1
m6.ToFraction();
cout << m6 << endl; // prints 1/1
cout << m6-m4 << endl; // prints -2/3
Mixed m7(0,3,4);
cout << m5*m7 << endl; // prints 2 (= 8/3 * 3/4)
cout << m5/m7 << endl; // prints 3 5/9 (32/9 = 8/3 * 4/3)
cout << "m4 == m4: " << boolalpha << (m4 == m4) << endl;
cout << "m5 != m4: " << boolalpha << (m5 != m4) << endl;
cout << "m5 > m4: " << boolalpha << (m5 > m4) << endl;
cout << "m5 >= m4: " << boolalpha << (m5 >= m4) << endl;
cout << "m4 < m5: " << boolalpha << (m4 < m5) << endl;
cout << "m4 <= m4: " << boolalpha << (m4 <= m4) << endl;
}

In: Computer Science

Assignment #3: Inferential Statistics Analysis and Writeup Part A: Inferential Statistics Data Analysis Plan and Computation...

Assignment #3: Inferential Statistics Analysis and Writeup

Part A: Inferential Statistics Data Analysis Plan and Computation

Introduction: I chose to imagine I am a 36 year old married individual with a large family. (UniqueID#30)

Variables Selected:

Table 1: Variables Selected for Analysis

Variable Name in the Data Set

Variable Type

Description

Qualitative or Quantitative

Variable 1: Marital Status

Socioeconomic

Marital Status of Head of Household

Qualitative

Variable 2: Housing

Expenditure

Total Amount of Annual Expenditure on Housing

Quantitative

Variable 3: Transport

Expenditure

Total Amount of Annual Expenditure on Transportation

Quantitative

Data Analysis:

1. Confidence Interval Analysis: For one expenditure variable, select and run the appropriate method for estimating a parameter, based on a statistic (i.e., confidence interval method) and complete the following table (Note: Format follows Kozak outline):

Table 2: Confidence Interval Information and Results

Name of Variable:

State the Random Variable and Parameter in Words:

Confidence interval method including confidence level and rationale for using it:

State and check the assumptions for confidence interval:

Method Used to Analyze Data:

Find the sample statistic and the confidence interval:

Statistical Interpretation:

2. Hypothesis Testing: Using the second expenditure variable (with socioeconomic variable as the grouping variable for making two groups), select and run the appropriate method for making decisions about two parameters relative to observed statistics (i.e., two sample hypothesis testing method) and complete the following table (Note: Format follows Kozak outline):

Table 3: Two Sample Hypothesis Test Analysis

Research Question:

Two Sample Hypothesis Test that Will Be Used and Rationale for Using It:

State the Random Variable and Parameters in Words:

State Null and Alternative Hypotheses and Level of Significance:

Method Used to Analyze Data:

Find the sample statistic, test statistic, and p-value:

Conclusion Regarding Whether or Not to Reject the Null Hypothesis:

Part B: Results Write Up

Confidence Interval Analysis:

Two Sample Hypothesis Test Analysis:

Discussion:

Data Set:

UniqueID#

SE-MaritalStatus

SE-Income

SE-AgeHeadHousehold

SE-FamilySize

USD-AnnualExpenditures

USD-Food

USD-Housing

USD-Transport

1

Not Married

95432

51

1

55120

7089

18391

115

2

Not Married

97469

35

4

54929

6900

18514

145

3

Not Married

96664

53

3

55558

7051

18502

168

4

Not Married

96653

51

4

56488

6943

18838

124

5

Not Married

94867

60

1

55512

6935

18633

131

6

Not Married

97912

49

1

55704

6937

18619

152

7

Not Married

96886

44

2

55321

6982

18312

153

8

Not Married

96244

56

4

56051

7073

18484

141

9

Not Married

95366

48

2

57082

7130

18576

149

10

Not Married

96727

39

2

56440

7051

18376

120

11

Not Married

96697

49

2

56453

6971

18520

136

12

Not Married

95744

52

4

55963

7040

18435

146

13

Not Married

96572

59

2

56515

7179

18648

123

14

Not Married

98717

40

3

56393

7036

18389

114

15

Not Married

94929

59

2

55247

6948

18483

133

16

Married

95778

42

4

73323

9067

22880

201

17

Married

109377

48

4

83530

10575

23407

99

18

Married

95706

52

4

71597

8925

22376

181

19

Married

95865

46

1

74789

9321

22621

168

20

Married

109211

42

4

82503

11566

22219

62

21

Married

95994

55

4

73404

9231

22852

177

22

Married

114932

44

5

81186

11077

26411

153

23

Married

112559

39

3

80934

11189

25531

73

24

Married

95807

56

4

72949

9210

23139

186

25

Married

99610

36

2

73550

9513

27164

33

26

Married

95835

54

3

73092

9111

23252

186

27

Married

102081

42

4

82331

11738

23374

121

28

Married

104671

41

4

82786

10420

22245

84

29

Married

107028

46

4

82816

10840

25671

109

30

Married

114505

36

5

78325

11375

26006

140

In: Math

DATA AND RESULTS Mass of Ball: .059 kg Trial Initial Height (yi) Final return height (yr)...

DATA AND RESULTS

Mass of Ball: .059 kg

Trial Initial Height (yi) Final return height (yr) Time to ground Time to return
1 4 m 2.2 m .882 s .644 s
2 3.5 m 2 m .830 .615 s
3 3 m 1.7 m .772 s

.561 s


1. The potential energy of the object at its highest point _2.32_Trial #1

2. The kinetic energy of the object just before impact _2.32 _

3. The velocity of the object just before impact, using kinetic energy _8.87 _

4. The “kinetic energy” of the object just after impact _33.80_ (Hint: neglect air resistance and think about the height it rebounds to)

5. The “rebound” velocity of the object _10.62_

6. The loss in energy _0 + 2.32 = 33.80 + 0 + loss_

Trial #2

1. The potential energy of the object at its highest point _2.03_

2. The kinetic energy of the object just before impact _2.03_

3. The velocity of the object just before impact, using kinetic energy _8.30 _

4. The “kinetic energy” of the object just after impact _-32.97_

5. The “rebound” velocity of the object __

6. The loss in energy __

Trial #3

1. The potential energy of the object at its highest point _1.74_

2. The kinetic energy of the object just before impact _1.74_

3. The velocity of the object just before impact, using kinetic energy _7.68 _

4. The “kinetic energy” of the object just after impact _-1.28_

5. The “rebound” velocity of the object _6.59_

6. The loss in energy __

Can someone please help me on this to double check I am doing this correctly? Thank you!

In: Physics

Give the charge of a central metal cation (Fe) in the complex ion for this compound:...

Give the charge of a central metal cation (Fe) in the complex ion for this compound: [Fe(H2O)3(Cl)(en)](NO3)2

Recommended time: 1 minute

+4

+1

+5

+2

+3

There might be two sigma bonds between two atoms in a molecule.    

Recommended time: 30 seconds

True

False

In: Chemistry

Helen has two children. Assume that the probability of each child being a girl is 50%,...

  1. Helen has two children. Assume that the probability of each child being a girl is 50%, and is independent with the gender of the other child. Given that at least one of Helen’s children is a girl, what is the probability that the other child is a boy?

    (A) 1/3 (B) 1/2 (C) 2/3 (D) 3/4 (SHOW WORK)

In: Statistics and Probability

1) explain macular degeneration and its effects to your sight? 2) what role does Schemm's canal...

1) explain macular degeneration and its effects to your sight?

2) what role does Schemm's canal play in glaucoma and how is glaucoma treated.? can it lead to blindness if untreated? why?

3) explain cataract formation and what causes it.?

4) explain the following:
1) convergence
2) accomodation
3) refraction

In: Anatomy and Physiology

QUESTION 21 Bravossi Inc. has two projects with the following cash flows: Year Project 1 Project...

QUESTION 21

  1. Bravossi Inc. has two projects with the following cash flows:

Year

Project 1

Project 2

0

(3,000.00)

(2,400.00)

1

1,000.00

1,500.00

2

??

800.00

3

1,500.00

??

4

1,800.00

1,400.00

IRR

26.2307%

33.8369%


  1. What is the crossover rate?

a.

8.4261%

b.

8.2041%

c.

7.6739%

In: Finance

Find the concentration of Fe+3 and NCS- in the following vials: Vial # .002 M Fe(NO3)3...

Find the concentration of Fe+3 and NCS- in the following vials:

Vial # .002 M Fe(NO3)3 .002 M KSCN Distiled Water

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

1 3 mL 1 mL 6 mL

2 3 mL 2 mL 5 mL

3 3 mL 3 mL 4 mL

In: Chemistry

Table 1: Customer Wait Time (in minutes) at the Downtown Lube & Oil SAMPLE Day 1...

Table 1: Customer Wait Time (in minutes) at the Downtown Lube & Oil
SAMPLE
Day 1 Day 2 Day 3 Day 4
Wait Time (minutes) 25 28 28 28
28 33 30 37
21 24 26 39
32 27 28 38
28 37 34 36
22 29 36 43
34 29 28 33
25 30 34 30
24 27 25 36
29 33 44 45

Sometimes both x-bar chart and p-chart are available to monitor the same process. In Table 1 above, you collect measurement data (wait times in minutes) to create an x-bar chart. You can also collect count data (pass/fail data) instead to create a p-chart. As you are curious about how it works, you decide to create a p-chart, too.

First, you convert the measurement data in Table 1 to count data using the following criteria:

Criteria

Not defective (i.e., wait time is appropriate)

25 minutes ≤ wait time ≤ 35 minutes

Defective (i.e., wait time is too short or too long)

wait time < 25 minutes or wait time > 35 minutes 1)

For example, the third wait time on Day 1 in Table 1 is 21 minutes. This is less than 25 minutes. Therefore, you count this as a defective. Table 2 shows the number of defectives.

Table 2: Number of Defectives

SAMPLE

Day 1

Day 2

Day 3

Day 4

Number of Defectives

3

2

2

7

Question 1

Based on the Table 2, determine the probability of defectives (p).

  1. p=0.35
  2. p=1.40
  3. p=3.50
  4. p=5.60
  5. p=14.00

Question 2

Continued from Question 1. Determine the standard deviation of p (σp). Round your answer to two decimal places.

  1. σp = 0.02
  2. σp = 0.08
  3. σp = 0.15
  4. σp = 0.24
  5. σp = 0.37

Question 3

Continued from Question 14. Determine three-sigma (i.e., z=3) upper and lower control limits for a p-chart. Round your answers to two decimal places.

  1. LCL=0.28, UCL=2.52
  2. LCL=0, UCL=1.07
  3. LCL=0, UCL=0.80
  4. LCL=0.12, UCL=0.58
  5. LCL=0.28, UCL=0.42

Question 4

Based on the p-chart, is the process in control? If not, which day(s) is not in control?

  1. Yes. The process is in control.
  2. No. Day 4 is not in control.
  3. No. Day 3 and Day 4 are not in control.
  4. No. Day 2, Day 3 and Day 4 are not in control.
  5. No. All days are not in control.

* I assume that customer wait times (population) are normally distributed with a mean of 30 minutes and a standard deviation of 5 minutes. This implies that the mean of customer wait times (sample mean) is normally distributed with a mean of 30 minutes and a standard deviation of 510 minutes, where 10 is the number of observations in each sample (i.e., sample size). Then, the upper and lower thresholds are calculated as 30±3510. *

In: Statistics and Probability

The daily changes in the closing price of stock follow a random walk. That is, these...

The daily changes in the closing price of stock follow a random walk. That is, these daily events are independent of each other and move upward or downward in a random matter and can be approximated by a normal distribution. Let's test this theory. Use either a newspaper, or the Internet to select one company traded on the NYSE. Record the daily closing stock price of your company for the six past consecutive weeks (so that you have 30 values). Decide whether the your 2 data sets are normally distributed by creating a histogram or a boxplot. Please attach your histogram or boxplot as a Word document in your post. Please do NOT answer the discussion in your attachment; answer on the discussion board. Discuss your results. What can you say about the stock with respect to daily closing prices and daily changes in closing prices. Which, if any, of the data sets are approximately normally distributed? NYSE - GE Date Closing Stock Price 1/2/19 8.05 1/3/19 8.06 1/4/19 8.23 1/7/19 8.74 1/8/19 8.56 1/9/19 8.5 1/10/19 8.94 1/11/19 8.94 1/14/19 8.9 1/15/19 8.73 1/16/19 8.98 1/17/19 9.14 1/18/19 9.06 1/22/19 8.66 1/23/19 8.73 1/24/19 8.78 1/25/19 9.16 1/28/19 8.93 1/29/19 8.9 1/30/19 9.1 1/31/19 10.16 2/1/19 10.19 2/2/19 10.21 2/3/19 10.63 2/4/19 10.47 2/5/19 10.06 2/6/19 9.81 2/7/19 10.03 2/8/19 9.81 2/12/19 10.31 Sample Size 30 Mean Median Standard Deviation Minimum Maximum

In: Statistics and Probability