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 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 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
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 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 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:
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 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

In: Economics
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
|
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