Questions
Part I The input to the program will be a text file containing the information for...

Part I The input to the program will be a text file containing the information for a tolerance table. An example follows using the values from the first lecture on tolerance analysis. These values will be stored in a text file. The data is comma delimited, which means that each data field is separated by a comma. If the first word is ‘PART’ the following values are the nominal size, +/- impact, tolerance, and fixed/variable. If the first word is ‘GAP’ the following values are the minimum and maximum gap sizes. (Note: assume all units are inches.) PART,2.000,-1,0.050,V PART,0.975,-1,0.025,V PART,3.000,+1,0.010,F GAP,0.000,0.080 These input values will be processed using the methods taught in class. A sample output for the first stage is given. Actual Gap Mean: 0.025” Actual Gap Tolerance: 0.085” The Maximum Gap (0.110”) is (Greater) than specified (0.080”) The Minimum Gap (-0.060”) is (Less) than the specified (0.000”)  

Part II The second stage extends the Stage 1 analysis. In this stage the program will suggest various combinations of part dimensions and tolerances to meet the gap specifications. The fixed dimension parts are not able to have their dimensions or tolerances adjusted. Take the required adjustment to all the variable parts and apply this adjustment to each part equally as a percentage of the total part dimension. Round dimensions to the nearest thousandth. Do the same application to adjust the gaps of all parts to have the gap fully use the available tolerance. Example Input: PART,2.000,-1,0.050,V PART,0.975,-1,0.025,V PART,3.000,+1,0.010,F GAP,0.000,0.080 Example Output: Recommended Adjustments to meeting GAP,0.000,0.80: PART,1.990,-1,0.020,V PART,0.970,-1,0.010,V PART,3.000,+1,0.010,F Math used to get to the result Variable parts should add to (3 – 0.04) = 2.96 Variable parts actually add to (2 + 0.975) = 2.975 All variable parts must be adjusted to 2.96/2.975 = 99.496% of the original value Variable tolerance should add to (0.04 – 0.01) = 0.03 Variable tolerance actually add to (0.05 + 0.025) = 0.075 All variable parts’ tolerance must be adjusted to 0.3/0.073 = 40% of the original value

Part III The third stage involves a statistical analysis called Monte Carlo simulation. Basically each of the dimensions is varied randomly and the gap is calculated. This random calculation is repeated hundreds or thousands of times. For each iteration, the individual gap value is calculated and stored in an array and in a file. The array of values will be used to compute the mean and standard deviation of the gap. The file will be opened using a spreadsheet program to graph a histogram, calculate an average, and calculate the standard deviation, which should match the result from your program. These values will then be used to estimate the number of rejected assemblies during production. It is reasonable to assume that the tolerance for a part is 3 standard deviations (99.73% of parts will fall within the tolerance). So for any part, we can generate random realistic values by taking the nominal value and adding/subtracting a random number, which represents variations due to the tolerance. To do this, we will need to generate a specific type of random numbers. The standard random number function in most programming language (rand() in C included) has a uniform distribution. This means that if we are finding random numbers from 0.0 to 1.0, the probability of getting 0.5 is the same as getting 0.1. This is not realistic for our application, since it will be more likely that we have our dimensions change by 0.1 than it is 0.5. For this reason, we need to modify the numbers from the rand() function so that they have a Gaussian (Normal) Distribution, which is sometimes referred to as the “bell curve”. This can be accomplished by using the Box-Muller Transformation. Although it sounds complicated, this transformation can be easily done and applied to generate a random dimension with the code given. Summary of Part 3: Apply the random_dimension() function below to get an output of a random_value of each part that will follow the explanation above. This will create a statistically likely value for each dimension given that you can then use to rerun the “actual mean gap” calculation from Part 1 1000 times. For each calculation, have the program store the value as a line in a text file (.csv extension.) You’ll be able to open this file up using Excel as a .csv file. In Excel, graph a histogram, calculate the average gap of all assemblies (of parts), and the standard deviation of the gap of all assemblies. void random_dimension(double nominal, double tolerance, double *random_value){ double r1, r2, r12; double sigma = tolerance / 3; do{ r1 = (double)( rand() % 10001 ) / 10000; }while(r1==0); r2 = (double)( rand() % 10001 ) / 10000; r12 = sqrt(-2*log(r1))*cos(2*M_PI*r2); *random_value = nominal + sigma * r12; }

In: Physics

Year Price of Tennis Balls Quantity of Tennis Balls Price of Golf Balls Quantity of Golf...

Year

Price of Tennis Balls

Quantity of Tennis Balls

Price of Golf Balls

Quantity of Golf Balls

Price of Gatorade

Quantity of Gatorade

2014 $2 100 $4 100 $1 200
2015 $2 100 $6 100 $2 200

Suppose that people consume only three goods, as shown in this table:

  • What is the percentage change in the price of each of the three goods?

  • Using the consumer price index, compute the percentage change in the overall price level.

  • If you were to learn that a bottle of Gatorade increased in size from 2014 to 2015, should that information affect your calculation of the inflation rate? If so, how?

  • If you were to learn that Gatorade introduced new flavors in 2015, should that information affect your calculation of the inflation rate? If so, how?

In: Economics

Design two function templates as follows: - First function template will be used to sort arrays...

Design two function templates as follows: -

First function template will be used to sort arrays of different data types in either descending or ascending order. This function template is required to have the following parameters: an array of a generic type, an integer representing the size of the array, and a character representing the order of sorting (i.e., ascending or descending). The last argument (i.e., the order of sorting) is required to be a default argument. The default order of sorting should be ascending.

- Second function template will be used to display an array. This function template is required to have two parameters: an array of a generic type and an integer representing the size of the array.

Design the main program that can be used to test both function templates above. The program should create the two dynamic arrays one of which will store integer values, while the other array will store character values. The size of both arrays will be determined at run time, i.e. entered by the user. The requested order of sorting (i.e., ascending or descending) for each array will also be obtained from the user at run time. The values stored in both arrays will be generated by the random numbers generator (i.e., srand() and rand() library functions could be used). Please note that the random characters' ASCII values should be in the range from 33 to 126, while the random integer numbers should be in the range from 1 to 100. The program will call both templates to sort arrays in the requested order and display both arrays before and after sorting. It is required to include all necessary error checking which includes the code to prevent any "garbage input" from the user as well as the code to prevent the memory allocation error.

In: Computer Science

Percentage Problem 6

The price of an item changed from $120 to $100. Then later the price decreased again from $100 to $80. Which of the two decreases was larger in percentage term?

In: Math

The spot offer price of Google stock is $1,044.15 and the offer price of a call...

The spot offer price of Google stock is $1,044.15 and the offer price of a call option with a strike price of $1,100 and a maturity date of September is $50.60. A trader is considering two alternatives: buy 100 shares of the stock and buy 100 September call options. For each alternative, what is (a) the upfront cost, (b) the total gain if the stock price in September is $1,250, and (c) the total loss if the stock price in September is $950. Assume that the option is not exercised before September and if stock is purchased it is sold in September.The spot offer price of Google stock is $1,044.15 and the offer price of a call option with a strike price of $1,100 and a maturity date of September is $50.60. A trader is considering two alternatives: buy 100 shares of the stock and buy 100 September call options. For each alternative, what is (a) the upfront cost, (b) the total gain if the stock price in September is $1,250, and (c) the total loss if the stock price in September is $950. Assume that the option is not exercised before September and if stock is purchased it is sold in September.

In: Accounting

Please use c++ and follow the instruction, I really want to fully understand this question and...

Please use c++ and follow the instruction, I really want to fully understand this question and I will use your code to check where I made mistake (Do not skip steps).

I have written my own code which has tons of errors, and I am so confused about this lab. I need help.

Lab 6.4 – C++ and Functions – Math Test

Critical Review

A value-returning function is a function that returns a value back to the part of the program that called it. In C++, you can use value-returning functions and those that do not.

y = sqrt(x);                    // value returning function

printBonus(stAmount, empAmount);// function returns no value

            Standard Library Functions

C++ comes with a standard library of functions that have already been written for you. These functions, known as library functions, make a programmer’s job easier because they perform many of the tasks that programmers commonly need to perform.

The rand Function

In order to use the random function in C++, you must include <cstdlib> library. You also should provide a random seed in order to get a random sequence every time you run the program by using <ctime> library. To do this, simply add the following line to the top of your code:

#include <cstdlib>

#include <ctime>  

Add the following statement in main before using the rand() function:

     srand(static_cast<unsigned int>(time(0)));

The rand() function typically returns a number between 0 and 32767. The following is how you would get a random number between 1 and 6.

value = rand() % 6 + 1;

Write a program that will allow a student to enter their name and then ask them to solve 5 mathematical equations. The program should display two random numbers that are to be added, such as:

247 + 129

The program should allow the student to enter the answer. The program should then display whether the answer was right or wrong and accumulate the correct values. After the 5 questions are asked, display the student name and the number correct.

In addition to any library functions you may use, you might consider the following functions:

  • A function that allows the student to enter their name.
  • A function that generates two random numbers, anywhere from 1 to 500.
  • A function that displays the equation and asks the user to enter their answer.
  • A function that calculates the results.
  • A function that displays the student name and the number right.

Your sample output might look as follows (random numbers will be different):

Enter student name: Katie<Enter>

Equation is 424 + 28

Enter the sum: 472<Enter>

Wrong

Equation is 163 + 233

Enter the sum: 396<Enter>

Right

Etc…(through 5 iterations)

Information for Katie

The number right: 3

The Pseudocode

Module main()

            //Declare local variables

            Declare Integer counter

            Declare String studentName

            Declare Integer right = 0

            Declare Integer number1

            Declare Integer number2

            Declare Integer answer

            Call srand(time(0))                                // to generate random sequence each time

            Set studentName = inputName()

            //Loop to run program again

            For counter = 1 to 5

                        //calls functions

Call generateNumbers(number1, number2)

Set answer = getAnswer(number1, number2)

                        If answer == number1 + number2 then

                                    Display “Right”

                                    Set right = right + 1

                        Else

                                    Display “Wrong”

                        End If

            End For

            Call displayInfo(right, studentName)

End Module

Function String inputName()

Declare String name

            Display “Enter student name: ”

            Input name

            Return name    

End Function

Module generateNumbers(Integer Ref number1, Integer Ref number2)

            Set number1 = rand() % 500 + 1

            Set number2 = rand() % 500 + 1

End Module

Function Integer getAnswer(Integer number1, Integer number2)

            Declare Integer answer

            Display “Equation is ”, number1, “+”, number2

            Display “Enter the sum: ”

            Input answer

            Return answer

End Function

Module displayInfo(Integer right, String studentName)

            Display “Information for ”, studentName

            Display “The number right:”, right

End Module

When your code is complete and runs properly, capture the output. Copy and paste both the source code and the output.

here is my work

#include<iostream>
#include<string>
#include <cstdlib>
#include <ctime>   

using namespace std;
void displayInfo(int right, string studentName);
void generateNumbers(int& number1, int& number2);
string inputName();

int main()
{
   //Declare local variables
   int counter;
   string studentName;
   int right = 0;
   int number1;
   int number2;
   int answer;
   srand(static_cast<unsigned int>(time(0)));
   // to generate random sequence each time
   studentName = inputName();
   //Loop to run program again
   for (counter = 1; counter <= 5; counter++)
   {
       generateNumbers(int& number1, int& number2);
       answer = getAnswer(number1, number2);
       if answer == number1 + number2
       cout << "Right";
       right = right + 1
       else
           cout << "Wrong";
   }
   void displayInfo(int right, string studentName);


//definition 1 input name

string inputName()
{
   string studentName;
   cout<< "Enter student name";
   cin>> name;
   return name;
}

//MODULE 2 generateNumbers
void generateNumbers(int& number1, int& number2)
{
   number1 = rand() % 500 + 1;
   number2 = rand() % 500 + 1;
}

//definition 3 getAnswer
int getAnswer(int number1, int number2)
{
   int answer;
   cout << "Equation is", number1, "+", number2;
   cout << "Enter the sum:";
   answer=answer1 + answer2;
   return answer
}

//MODULE 4 displayInfo
void displayInfo(int right, string studentName)
{
   cout << "Information for" << studentName;
   cout << "The number right" << right;
}

In: Computer Science

Consider the following US government (risk-free) bonds: Bond A: 2-year note issued one year ago with...

Consider the following US government (risk-free) bonds:

Bond A: 2-year note issued one year ago with a coupon rate of 5%

Bond B: 3-year note issued two years ago with a coupon rate of 5%

The price of the first bond is 100 and the price of the second bond is 101. For simplicity, assume that investors do not face margin requirements or interest payments to short-sell assets.

a. Assume there are no transaction costs. Establish an arbitrage trade to profit from the pricing of these bonds. What would be the profit in USD per pair of bonds traded?

b. Assume that transaction costs are 1% of the face value of the bond per transaction. Selling and buying a bond are two separate transactions. What is the net gain/loss of implementing the strategy from the previous question?

c. The US government issues a one-year bond that makes semi-annual coupons with one year maturity and $100 face value. Under the absence of arbitrage assumption, what would be the price of this bond if:

i. Bond A is correctly priced and Bond B is incorrectly priced?

ii. Bond B is correctly priced and Bond A is incorrectly priced?

In: Finance

After graduating, you start work as a management consultant. You are paid $150 per hour: One...

4. Search with imperfect information After graduating, you start work as a management consultant. You are paid $150 per hour one morning before work, you decide to buy a new car. $35,500 to $36,500 with the You know the exact model you w nd you know that in your area the price ranges from average price ant, a you can expect to get being $36,000. You can choose among hundreds of dealers, but you dont know which dealer will give you the best price. Time is literally money, since every hour you spend searching is an hour you dont get paid. Each visit to a dealer takes an hour Your expected marginal benefit of another search is the difference between the current dealers offer and the average price. to asks $36,300 for the c Should you The first dealer pt the price or keep searching? (Keep in mind that each visit to a dealer takes an you go hour O Keep searching O Accept the price. to asks $36,100. Do you think you should accept this price or keep searching? Suppose you kept searching, a nd the next dealer you go O Keep searching O Accept the price. Suppose you kept searching, a nd the next dealer to asks $36,130. You could return to the last dealer (who offered you a price of $36,100) but you go that would take another hour What should you do? O Return to the last dealer and pay $36,100. O Get a new price from yet another dealer O Accept the price of $36,130 which of the following best explains how it can be profitable for different dealers to offer different prices O Some dealers have lower costs than others. O Some dealers have higher costs than others It he higher-priced dealers will lose money in the long run isnt-t O Because different people have different opportunity costs of their time, even high-priced dealers can sometimes make sales

After graduating, you start work as a management consultant. You are paid $150 per hour: One morning before work, you decide to buy a new car. You know the exact model you want, and you know that in your area the price ranges from $35, 500 to $36, 500 with the average price you can expect to get being $36,000. You can choose among hundreds of dealers, but you don't know which dealer will give you the best price.
 
Time is literally money, since every hour you spend searching is an hour you don't get paid. Each visit to a dealer takes an hour. Your expected marginal benefit of another search is the difference between the current dealer's offer and the average price.
 
The first dealer you go to asks $36, 300, for the car. Should you accept the price or keep searching? (Keep in mind that each visit to a dealer takes an hour, ) Keep searching. Accept the price.
 
Suppose you kept searching, and the next dealer you go to asks $36, 100. Do you think you should accept this price or keep searching? Keep searching. Accept the price.
 
Suppose you kept searching, and the next dealer you go to asks $36, 130. You could return to the last dealer (who offered you a price of $36, 100) but that would take another hour. What should you do? Return to the last dealer and pay $36, 100. Get a new price from yet another dealer. Accept the price of $36, 130.
 
Which of the following best explains how it can be profitable for different dealers to offer different prices? Some dealers have lower costs than others. Some dealers have higher costs than others. It isn't-the higher-priced dealers will lose money in the long run. Because different people have different opportunity costs of their time, even high-priced dealers can sometimes make sales.

In: Economics

The average price for a gallon of gas in the United States is $1.80. Assume that...

The average price for a gallon of gas in the United States is $1.80. Assume that the population standard deviation is $0.50. (a) What is the probability that a sample of 100 gas stations will have a mean price per gallon within ±$0.06 of the population mean? (b) What is the probability that a sample of 100 gas stations will have a mean price per gallon of more than $1.77? (c) What is the probability that a sample of 100 gas stations will have a mean price per gallon of less than $1.86?

In: Statistics and Probability

Economic Growth (10 Marks) 2017 2018 Product Quantity Price Quantity Price Backpacks 100 $10 120 $12...

  1. Economic Growth

2017

2018

Product

Quantity

Price

Quantity

Price

Backpacks

100

$10

120

$12

Books

50

$15

40

$20

Using 2017 as a base year, calculate;

1) The GDP deflator

2) Nominal Economic growth

3) Real economic growth

4) Give reasons why Real GDP per capita may overstate the well-being of a countries inhabitants?

make as per Canadian standards.

             

             

In: Economics