MAE 2360 F ALL 2018
HOMEWORK 1
Change the title Homework or Lab Report accordingly
NAME :
1000 NUMBER:
DATE SUBMITTED:
I promise that I did all the work by myself without help from other students. I
understand that violating this promise will result in automatic 0 point and
penalties as severe as expulsion from UTA.
QUESTION-1:
DESCRIPTION
Describe what the questions asks and what are given. Introduce your method of
choice and algorithm. Do not rewrite the question. Example:
This question asks to write a C program which will display “Hello World” on the screen three
times separated by new lines. For this reason we can use printf function inside a for loop.
CODE AND COMMENTS
Rewrite the code with the comment lines. Code should be clear, easily readable.
Do not put a screenshot, you must type/copy the code. Example :
#include
int main(){
int k;
for (k = 0; k < 3; k++) // this loop run 3 times
printf(“Hello World\n”) ; //
\n is new line
return 0;
}
TEST CASES:
Here you will demonstrate your code is working by showing the execution results.
In some questions you will be asked to satisfy more than one requirement. In
these cases, you need to show the execution of separate test cases and prove your
code is capable of all requirements.
Fig. 1: Test case for the first question.
If you insert a screenshot or any figure related to your solution, make sure figure is
clear, distinctive and well-formatted: numbered, captioned and referenced within the
text as can seen in Fig. 1.
Use Snipping tool to take the screenshot of only the point of interest. Do not put the
screenshot of an entire computer screen.
If you are asked to show your hand calculations, you should scan your handwritten
work and insert them as new pages. You are not suggested to take photos as the
resulting images are unintelligible and you can lose all the points if the GTA cannot
clearly see your work.
DO NOT forget to save your submission as a pdf file
before submitting to Blackboard. i.e hw_01_doe_john.pdf
MAE 2360 F ALL 2018
HOMEWORK 1
Change the title Homework or Lab Report accordingly
NAME :
1000 NUMBER:
DATE SUBMITTED:
I promise that I did all the work by myself without help from other students. I
understand that violating this promise will result in automatic 0 point and
penalties as severe as expulsion from UTA.
QUESTION-1:
DESCRIPTION
Describe what the questions asks and what are given. Introduce your method of
choice and algorithm. Do not rewrite the question. Example:
This question asks to write a C program which will display “Hello World” on the screen three
times separated by new lines. For this reason we can use printf function inside a for loop.
CODE AND COMMENTS
Rewrite the code with the comment lines. Code should be clear, easily readable.
Do not put a screenshot, you must type/copy the code. Example :
#include
int main(){
int k;
for (k = 0; k < 3; k++) // this loop run 3 times
printf(“Hello World\n”) ; //
\n is new line
return 0;
}
TEST CASES:
Here you will demonstrate your code is working by showing the execution results.
In some questions you will be asked to satisfy more than one requirement. In
these cases, you need to show the execution of separate test cases and prove your
code is capable of all requirements.
Fig. 1: Test case for the first question.
If you insert a screenshot or any figure related to your solution, make sure figure is
clear, distinctive and well-formatted: numbered, captioned and referenced within the
text as can seen in Fig. 1.
Use Snipping tool to take the screenshot of only the point of interest. Do not put the
screenshot of an entire computer screen.
If you are asked to show your hand calculations, you should scan your handwritten
work and insert them as new pages. You are not suggested to take photos as the
resulting images are unintelligible and you can lose all the points if the GTA cannot
clearly see your work.
DO NOT forget to save your submission as a pdf file
before submitting to Blackboard. i.e hw_01_doe_john.pdf
Assignment
1. Experimental data are collected as:
data[100]={-92.3973, 14.0677,98.9626,49.6151, 111.88,-38.7967,52.1535,-101.325,65.6111,125. 129, 151.762,
-123. 132,-41.8744,-39.3356,-99.7856,-128.881,58.5477, -111.692, -75.3057,4.4723, -100.051,169.051,
-15.6953,58.3125, 147.346, 10.9835,42.3421,166.697,-105.534,-90.2199,151.189,130.022,-8.1448,-51.3493,
164.427,119.154,-99.2704,155.986,133.212,118.035, 13.1819, 139.678, 81.5178,-12.4377,-11.7671,146.627,
-25.787,107.25, 19.8867,15.6437,112.871,122.552,8.42037, -10.1364, 146.682,178.531,203.565, -70.7871,
171.256,-50.6232, 193.836,-34.7733,-68.9564, 25.3423,75.6537,21.5484,46.5259,-64.22,-13.5792,
74.9213,-26.6872,30.5302,169.534,-36.7224,65.4419,113.978,68.1137,181.414, 127.76,145.447,75.5486,
164.201,169.504,110.07,96.713, 114.974,155.46,2.72803,-59.9407,13.426,29.9344,-11.052,176.639,
162.505, -18.3784,184.418,234.104,127.227,145.18, 0.440172};
a. Write two C functions to compute mean and standard deviation based on the template given below.
b. Calculate mean and standard deviation of whole data and print on the console.
c. Calculate mean and standard deviation of first half, print on the console.
#include
float average (float a[], int s ) {
// fill this part
}
float stddev (float a[], int s ){
// fill this part
// you should call average) here
}
int main() {
float data[100] = { ...
return 0;
}
2. You are going to design a simple game. Player will throw two dices.
• Player wins the bet if the sum is 7 or 11.
• Player loses the bet if the sum is 2, 3 or 12.
• In this simplified game Player neither loses or wins the bet if the sum is anything else.
• Print a message about the result.
3. Using the Monte Carlo method, integrate
1
1
dx
1 + x2
numerically. Vary the number of iterations (10, 1000, 10,000 ...) and estimate an appropriate number of iterations to obtain good accuracy.
1
1/(1+x**2)
0.8
0.6
0.4
0.2
0
0
0.2
0.4
0.6
0.8
Note: The exact value of the above integration is 1/4 so this can be used to approximate the value of n.
Make sure that you attach example runs showing the results from the computer.
Purchase answer to see full
attachment