Assignment6A: This used to be entertainment. If you haven’t played the classic game Pong, then you are now required to do so. Though it doesn’t capture the poor quality of the original, you can find an emulator at Pong-2.com. Play it (using the keyboard). Do you see how the ball bounces off of the walls and the paddles? You’re going to learn how to do this by creating class Ball.
A Ball has an X and Y position. Equally important, a ball has an
x velocity and a y velocity. Every time the ball moves (in one unit
of time), it changes its X and Y position by its x and y velocity.
However, before moving it, you need to check to see if it’s
touching a wall. If so, you need to reverse either its x or y
velocity depending on whether or not its touching a wall. What is
the ball’s location if its touching a wall? For simplicity, we’re
going to assume that the ball is on a 10x10 field and that the x
and y velocities can only be -1, 0, or +1.
Your task is to 1) write class Ball that has the variables/attributes above, 2) has a constructor that takes in the starting X and Y position as well as the starting X and Y velocity, 3) has a method called “move” that takes no parameters and updates the position of the ball and 4) has a print statement called “print” that takes no parameters and prints out the ball’s current position.
You must call the class “Ball” and put it in a file called Ball(.java, .cs, .cpp, .h). To test your ball, you should create a file called Assignment6A(.java, .cs, .cpp) that creates a ball based off of user input and calls the “move” and “print” methods of the ball the number of times the user wants. It should behave like the sample output below.
|
Sample Output #1: x: 7 y: 4 x velocity: 1 y velocity: 1 Number of moves: 20 X:7 Y:4 X:8 Y:5 X:9 Y:6 X:8 Y:7 X:7 Y:8 X:6 Y:9 X:5 Y:8 X:4 Y:7 X:3 Y:6 X:2 Y:5 X:1 Y:4 X:0 Y:3 X:1 Y:2 X:2 Y:1 X:3 Y:0 X:4 Y:1 X:5 Y:2 X:6 Y:3 X:7 Y:4 X:8 Y:5 X:9 Y:6 |
Sample Output #2: x: 5 y: 2 x velocity: 0 y velocity: -1 Number of moves: 20 X:5 Y:2 X:5 Y:1 X:5 Y:0 X:5 Y:1 X:5 Y:2 X:5 Y:3 X:5 Y:4 X:5 Y:5 X:5 Y:6 X:5 Y:7 X:5 Y:8 X:5 Y:9 X:5 Y:8 X:5 Y:7 X:5 Y:6 X:5 Y:5 X:5 Y:4 X:5 Y:3 X:5 Y:2 X:5 Y:1 X:5 Y:0 |
In: Computer Science
let A= {1,2} and C={8,9}. for each i=1,2, construct
sets B sub i as well as functions f sub i: A to B sub I,
1<=i<=4, with the following properties:
1) g sub 1 ° f sub 1 is onto C but f sub 1 is not onto B sub
I.
2) g sub 2° f sub 2 is one-to-one but g sub 2 is not
one-to-one.
In: Advanced Math
Show the conversion of the following numbers with the standard conversion procedure.
1. (AD)H = ( ?)2 = ( ? )10
2. (24)7 = ( ? )10 = ( ? )2
3. ( 10011001)2 = ( ? )8 = (?)16
4. (334.2301)10 = ( ? )2
In: Advanced Math
(IN C)
What are the contents of the array after the for-loop in the following code?
int array[ SIZE ][ SIZE ] = { { 4, 5, 6, 7, 8 },
{ 1, 2, 3, 4, 5 },
{ 3, 6, 7, 8, 9 },
{ 2, 3, 4, 5, 6 },
{ 5, 6, 7, 8, 9 } };
int i;
int *ptr = array[ 0 ];
for( i = 0; i < SIZE * SIZE; i++ ) {
if( i % SIZE < 2 ) {
*( ptr + i ) = 0;
}
else if( i % SIZE == 2 ) {
*( ptr + i * SIZE ) = 100;
}
}
In: Computer Science
In: Math
Simplify. Do not give trig values.
1) 2 sin40 cos 40
2) 10 sin 18 cos 18
3) (tan 22)^2
4) 2 (cos 37)^2 - 1
5) (cos 29)^2 - 1
6) (sin 33)^2 + (cos 33)^2
7) (sin 38)^2 - (cos 38)^2
8) cos 67 cos 31 + sin 67 sin 31
9) cos 81 cos 53 - sin 81 sin 53
10) cos 46 / sin 46
11) sin 50 / cos 40
12) sin 44 cot 44
13) 4 (sin 31)^2 (cos 31)^2 "think double angle"
14) sin 38 + cos 38
15) sin 40 + cos 32 "sum to product rule"
16) sin 53 cos 67 "product to sum rule"
In: Math
Question 4 :In the planning of the monthly production for the next four months, in each month a company must operate either a normal shift or an extended shift (but not both) if it produces. It may choose not to produce in a month. A normal shift costs $100,000 per month and can produce up to 5,000 units per month. An extended shift costs $140,000 per month and can produce up to 7,500 units per month.
The cost of holding inventory is estimated to be $2 per unit per month (based on the average inventory held during each month) and the initial inventory is 3,000 units (i.e., inventory at the beginning of Month 1). The inventory at the end of month 4 should be at least 2,000 units. The demand for the company's product in each of the next four months is estimated to be as shown below:
|
Month |
1 |
2 |
3 |
4 |
|
Demand |
6000 |
6500 |
7500 |
7000 |
Production constraints are such that if the company produces anything in a particular month it must produce at least 2,000 units. The company wants a production plan for the next four months to meet its demands. Formulate an integer programming model to solve the problem at minimum cost.
Decision variables :
Objective function :
Constraints :
Additional constraint 1 :The company can operate an extended shift in Month 1 only if it operates a normal shift in each of Month 2, Month 3 and Month 4.
Additional constraint 2 :The company must produce in either Month 1 or Month 2 (or both) if it does not produce in Month 3.
Additional constraint 3 :For each of Month 2, 3 and 4,the company cannot operate an extended shift in a month if it operates one in the previous month.
In: Statistics and Probability
QDM Question 4 : In the planning of the monthly production for the next four months, in each month a company must operate either a normal shift or an extended shift (but not both) if it produces. It may choose not to produce in a month. A normal shift costs $100,000 per month and can produce up to 5,000 units per month. An extended shift costs $140,000 per month and can produce up to 7,500 units per month.
The cost of holding inventory is estimated to be $2 per unit per month (based on the average inventory held during each month) and the initial inventory is 3,000 units (i.e., inventory at the beginning of Month 1). The inventory at the end of month 4 should be at least 2,000 units. The demand for the company's product in each of the next four months is estimated to be as shown below:
|
Month |
1 |
2 |
3 |
4 |
|
Demand |
6000 |
6500 |
7500 |
7000 |
Production constraints are such that if the company produces anything in a particular month it must produce at least 2,000 units. The company wants a production plan for the next four months to meet its demands. Formulate an integer programming model to solve the problem at minimum cost.
Decision variables :
Objective function :
Constraints :
Additional constraint 1 : The company can operate an extended shift in Month 1 only if it operates a normal shift in each of Month 2, Month 3 and Month 4.
Additional constraint 2 : The company must produce in either Month 1 or Month 2 (or both) if it does not produce in Month 3.
Additional constraint 3 : For each of Month 2, 3 and 4, the company cannot operate an extended shift in a month if it operates one in the previous month.
In: Operations Management
following are two weekly forecasts made by two different methods for the number of gallons of gasoline, in thousands, demanded at a local gasoline station. Also shown are actual demand levels in thousands of gallons:
Forecasts
week Method 1 Method 2 Actual Demand
1 0.90 0.80 0.70
2 1.05 1.20 1.00
3 0.95 0.90 1.00
4 1.20 1.11 1.00
The MAD method 1 = ??? thousand gallons... 2. The absolute deviatin based on the forecast developed using Method 1 adds to ??? thousand gallons. Mean squared error (MSE) is the average of (actual-Forecast). from the information given in method 1 , the value of n=4. the value E(autal-forecast) will be??? thousand gallons.
In: Other
QUESTION 47
Which of the following investors is more likely to engage in overconfidence bias?
|
a. A pension fund manager operating within strict portfolio allocation requirements. |
||
|
b. A novice investor allocating the majority of their funds to index investing. |
||
|
c. An investor with a few years' experience selecting stocks after examining the risk and return expectations of several stocks. |
||
|
d. A fund manager with several years' experience outperforming the market. |
QUESTION 48
Which of the following behavioral finance errors does research indicate are likely to be made by professional money managers? (1) Herding. (2) Confirmation bias. (3) Overconfidence bias. (4) Mental accounting.
|
a. 1 and 2. |
||
|
b. 1 and 4. |
||
|
c. 1 and 3. |
||
|
d. 1, 2 and 3. |
In: Finance