Main Program's grading:
Student's main program will be used to generate output files. These output files will be compared to the solution output files and also to output files generated through instructor code, i.e., C++ code that will call the appropriate members of the Board class with the appropriate command line arguments. Students are free to impliment their main program however they like but the output must be correct (according to the solution) and must match the output using student's Board class. Pseudocode for generating the output files from the instructor's end is shown below
#include "Cell.hpp"
#include "Board.hpp"
#include "Gary.hpp"
int main(int argc, char** argv){
unsigned int boardSize = (from command line arguments)
unsigned int numberSteps = (from command line arguments)
std::string outputFilename = (from optional command line argument)
Board B(boardSize);
if (an output filename is given){
B.setOutputFilename(outputFilename);
}
B.move_gary(numberSteps);
return 0;
}
and student code must be capable of generating the correct output in the correct location when calling these member functions of the Board class. Please note that the only "pseudo" above is the parsing of command line arguments and the if statement - the member functions and construction of variable B of type Board is valid C++ syntax that is used during testing.
Board Class:
Note that there are no structural requirements for the Board class beyond the member functions called via the above psuedo-main program. These include:
(1) The Board class shall be constructed given an unsigned integer parameter that defines the number of rows and columns, i.e., 'N' in the N by N board. Note that N must be odd. If N is given as even, students shall display a message stating "Board dimension must be an odd number!! Got {N} and adding 1 to equal {N+1}" (note that parameters within { } must be printed as their values) and shall add 1 to N to satisfy the requirement that N must be odd. Note that this message must be printed only to the console, i.e., should not be printed to the output file. (2) Gary shall move around the board when the move_gary(steps) function is called. Each step shall be one step of Langton's ant as defined above, i.e., change Gary's orientation based on the Cell input, change the cell color, and move Gary forward one unit. The board class shall print the state of the board at every step. See the below example with a boardSize input of 5 for 10 steps:
[Gary Location] {2, 2} [Gary Orientation] up [Row 0] 0 0 0 0 0 [Row 1] 0 0 0 0 0 [Row 2] 0 0 0 0 0 [Row 3] 0 0 0 0 0 [Row 4] 0 0 0 0 0
[Gary Location] {2, 3} [Gary Orientation] right [Row 0] 0 0 0 0 0 [Row 1] 0 0 0 0 0 [Row 2] 0 0 1 0 0 [Row 3] 0 0 0 0 0 [Row 4] 0 0 0 0 0
[Gary Location] {3, 3} [Gary Orientation] down [Row 0] 0 0 0 0 0 [Row 1] 0 0 0 0 0 [Row 2] 0 0 1 1 0 [Row 3] 0 0 0 0 0 [Row 4] 0 0 0 0 0
[Gary Location] {3, 2} [Gary Orientation] left [Row 0] 0 0 0 0 0 [Row 1] 0 0 0 0 0 [Row 2] 0 0 1 1 0 [Row 3] 0 0 0 1 0 [Row 4] 0 0 0 0 0
[Gary Location] {2, 2} [Gary Orientation] up [Row 0] 0 0 0 0 0 [Row 1] 0 0 0 0 0 [Row 2] 0 0 1 1 0 [Row 3] 0 0 1 1 0 [Row 4] 0 0 0 0 0
[Gary Location] {2, 1} [Gary Orientation] left [Row 0] 0 0 0 0 0 [Row 1] 0 0 0 0 0 [Row 2] 0 0 0 1 0 [Row 3] 0 0 1 1 0 [Row 4] 0 0 0 0 0
[Gary Location] {1, 1} [Gary Orientation] up [Row 0] 0 0 0 0 0 [Row 1] 0 0 0 0 0 [Row 2] 0 1 0 1 0 [Row 3] 0 0 1 1 0 [Row 4] 0 0 0 0 0
[Gary Location] {1, 2} [Gary Orientation] right [Row 0] 0 0 0 0 0 [Row 1] 0 1 0 0 0 [Row 2] 0 1 0 1 0 [Row 3] 0 0 1 1 0 [Row 4] 0 0 0 0 0
[Gary Location] {2, 2} [Gary Orientation] down [Row 0] 0 0 0 0 0 [Row 1] 0 1 1 0 0 [Row 2] 0 1 0 1 0 [Row 3] 0 0 1 1 0 [Row 4] 0 0 0 0 0
[Gary Location] {2, 1} [Gary Orientation] left [Row 0] 0 0 0 0 0 [Row 1] 0 1 1 0 0 [Row 2] 0 1 1 1 0 [Row 3] 0 0 1 1 0 [Row 4] 0 0 0 0 0
[Gary Location] {3, 1} [Gary Orientation] down [Row 0] 0 0 0 0 0 [Row 1] 0 1 1 0 0 [Row 2] 0 0 1 1 0 [Row 3] 0 0 1 1 0 [Row 4] 0 0 0 0 0
the format is given by [Gary Location] {(row), (col)} (orientation) [Row 0] (col 0 color) (col 1 color) ... (col N-1 color) [Row 1] ... [Row (N-1)] ... (col N-1 color) where values within ( ) are to be filled in with program values. (col i color) shall be either "0" for "white" or "1" for "black". Note that students may want to call Cell::get_color_string( ) to print this value (or just Cell::get_color() as pointed out by a student in office hours!). This output will either be to standard output, i.e., std::cout, if a filename command line argument is not provided or will be printed to the filename given in the argument (students should use the ofstream object for file output. Note that C's fprintf will also be okay). The filename shall be set with the setOutputFilename member function.
Students are free to impliment the remaining functionality of the Board class as desired. The class should store a representation of the actual grid of cells which define the environment for Langon's ant, i.e., the Cell class created in Part A (Hint: I utilized a vector of vectors where each element of the outer vector stores a "row" or the grid represented by a vector of class Cell). The board class must also store a variable of type Gary that "walks" about the board. (More information on Gary is given below) At each step in the Gary::move_gary(Cell*) function the Board must pass a pointer to the Cell that Gary currently occupies so that Gary can alter his orientaiton, flip the color of that cell, i.e., call the change_color member function, and change his position, i.e., "walk" (find a tutorial for pointers to objects here).
The Gary class is subject to C++ unit testing and therefore has stricter requirements for composition. Each required member function will be denoted. (
1) Gary shall be constructed with a parameterized constructor accepting an unsigned integer input parameter representing the size of the board (denote here as BoardSize). Assume that BoardSize is odd! Gary shall initialize his position to be the middle cell of the board, e.g., if the BoardSize is given as 5 Gary would be initialized at index (2,2).
(2) Gary shall contain public member functions which return an unsigned integer type and accept no input named Gary::get_row() and Gary::get_col() which return Gary's row and column position on the board respectively.
(3) Gary shall contain a public member function which returns type void and accepts a Cell pointer called Gary::move(Cell*) which shall (a) alter Gary's orientation based on the Cell's color (b) change the Cell's color (c) move Gary one unit forward in the new orientation
(4) Gary shall contain a public member function which returns type orientation (defined as an enumeration enum orientation {up, right, down, left};) and accepts no input parameters called Gary::get_orientation()
In: Computer Science
Question 5: (Marks: 5)
A group of students compared the number of times they have been to the movies in the past year. The following table illustrates how many times each person went to the movie theatre in each month. You need to show your work.
|
Jan. |
Feb. |
Mar. |
Apr. |
May |
June |
July |
Aug. |
Sep. |
Oct. |
Nov. |
Dec. |
|
|
Eric |
1 |
2 |
3 |
5 |
2 |
1 |
3 |
1 |
2 |
1 |
3 |
1 |
|
Kyle |
1 |
2 |
1 |
3 |
1 |
2 |
3 |
2 |
2 |
1 |
4 |
2 |
|
Stan |
1 |
3 |
2 |
2 |
2 |
1 |
5 |
3 |
2 |
2 |
3 |
3 |
|
Kenny |
1 |
2 |
1 |
1 |
2 |
2 |
3 |
2 |
3 |
2 |
3 |
2 |
In: Statistics and Probability
| SEX: Sex (1=Male 2=Female) | WEIGHT: Body Weight (kg) |
| 1 | 61.236 |
| 1 | 79.38 |
| 1 | 99.792 |
| 1 | 81.648 |
| 1 | 72.576 |
| 1 | 61.236 |
| 1 | 83.916 |
| 1 | 97.524 |
| 1 | 88.452 |
| 1 | 79.38 |
| 2 | 57.607 |
| 2 | 64.184 |
| 2 | 63.958 |
| 2 | 133.358 |
| 2 | 62.143 |
| 2 | 58.968 |
| 2 | 58.514 |
| 2 | 61.69 |
| 2 | 107.503 |
| 2 | 83.009 |
Open Brain data. Claim: Male and female subjects have different weight.
9. What test/procedure did you perform?
10. What is the P-value/margin of error?
11. Statistical interpretation
12. Conclusion
In: Statistics and Probability
(a).Verify multiplication of M x N mod 26 = N x M mod 26 = I (identity matrix)
(b). Use Hill cipher to encrypt the message EXAMS
In: Computer Science
Kelson Sporting Equipment, Inc., makes two different types of baseball gloves: a regular model and a catcher’s model. The firm has 900 hours of production time available in its cutting and sewing department, 300 hours available in its finishing department, and 100 hours available in its packaging and shipping department. The production time requirements and the profit contribution per glove are given in the following table:
|
Production Time (hours) |
||||
|
Cutting |
Packaging |
|||
|
Model |
and Sewing |
Finishing |
and Shipping |
Profit/Glove |
|
Regular model |
1 |
1/2 |
1/8 |
$5 |
|
Catcher's model |
3/2 |
1/3 |
1/4 |
$8 |
Assume that the company is interested in maximizing the total profit contribution.
Let R = number of units of regular model.
C = number of units of catcher’s
model.
|
Max |
5 R |
+ |
8 C |
|||
|
s.t. |
||||||
|
1 R |
+ |
3/2 C |
≤ |
900 |
Cutting and sewing |
|
|
1/2 R |
+ |
1/3 C |
≤ |
300 |
Finishing |
|
|
1/8 R |
+ |
1/4 C |
≤ |
100 |
Packaging and Shipping |
|
|
R, C |
≥ |
0 |
It should have: (or least how to do it)
User Interface.
VBA Code to link Model and Interface
VBA Code for Formatting
VBA Code for Error Trapping
Thank you!
In: Operations Management
The data shown provides some demographic and opinion data on whether the economy is moving in the right direction.
As you work, do not move the data from the original location. Otherwise, the cell references in your formulas will be different from mine so when you are asked for Excel formulas on the Blackboard quiz, your answer could be maked wrong.
(a) On the right, give the distribution of the political party affiliation in terms of frequency and % frequency.
(b) In this sample, which party affiliation occurred most frequently? Which was the least frequent?
(c) What % of the respondents have pessimistic perception on the economy (No on Economy Perception)?
(d) Filter the data to show only the respondents who are home owners (Yes on Home Owner) and are optimistic (Yes on Economy Perception). How many such respondents are there?
(e) Optional - Extra credit: Answer (d) by using =COUNTIFS function. Use the criteria "Yes" for both conditions. In Blackboard submission, you will be asked to copy and paste the function you used here.
| c | Age | Gender | Years College | Political Party | Home Owner | Voted in Last Election | Economy Perception |
| 1 | 32 | Male | 2 | Democrat | Yes | Yes | Yes |
| 2 | 35 | Female | 2 | Republican | No | Yes | No |
| 3 | 29 | Female | 4 | Independent | No | No | No |
| 4 | 31 | Female | 0 | Republican | No | Yes | No |
| 5 | 32 | Male | 5 | Republican | No | Yes | No |
| 6 | 66 | Female | 4 | Republican | Yes | Yes | No |
| 7 | 64 | Male | 4 | Republican | Yes | Yes | No |
| 8 | 22 | Male | 3 | Democrat | No | Yes | Yes |
| 9 | 21 | Male | 2 | Republican | No | Yes | No |
| 10 | 33 | Female | 1 | Independent | No | Yes | No |
| 11 | 38 | Male | 0 | Independent | No | No | No |
| 12 | 31 | Female | 0 | Republican | No | Yes | No |
| 13 | 39 | Male | 4 | Democrat | No | Yes | Yes |
| 14 | 30 | Male | 0 | Independent | No | No | No |
| 15 | 52 | Female | 5 | Republican | Yes | Yes | No |
| 16 | 35 | Female | 2 | Republican | No | Yes | No |
| 17 | 29 | Male | 4 | Democrat | No | Yes | Yes |
| 18 | 29 | Female | 0 | Democrat | No | Yes | No |
| 19 | 20 | Male | 1 | Independent | No | No | No |
| 20 | 32 | Female | 2 | Democrat | No | Yes | Yes |
| 21 | 32 | Male | 2 | Independent | No | Yes | No |
| 22 | 31 | Female | 2 | Independent | Yes | No | No |
| 23 | 37 | Female | 4 | Independent | No | Yes | No |
| 24 | 29 | Male | 3 | Independent | No | No | No |
| 25 | 38 | Male | 0 | Independent | No | Yes | No |
| 26 | 21 | Male | 2 | Republican | No | Yes | No |
| 27 | 41 | Male | 4 | Republican | No | Yes | No |
| 28 | 26 | Female | 4 | Independent | Yes | No | No |
| 29 | 25 | Female | 1 | Republican | Yes | Yes | No |
| 30 | 30 | Male | 4 | Republican | Yes | Yes | Yes |
| 31 | 27 | Female | 0 | Democrat | No | No | No |
| 32 | 32 | Female | 4 | Independent | No | No | No |
| 33 | 37 | Male | 2 | Democrat | Yes | Yes | Yes |
| 34 | 33 | Male | 2 | Democrat | No | No | No |
| 35 | 27 | Male | 2 | Republican | No | Yes | No |
| 36 | 30 | Female | 6 | Independent | Yes | Yes | No |
| 37 | 27 | Female | 0 | Independent | Yes | Yes | Yes |
| 38 | 28 | Female | 2 | Democrat | Yes | Yes | Yes |
| 39 | 27 | Female | 5 | Independent | Yes | Yes | No |
| 40 | 64 | Male | 4 | Independent | Yes | Yes | No |
| 41 | 34 | Female | 7 | Independent | Yes | Yes | No |
| 42 | 30 | Male | 5 | Republican | Yes | Yes | No |
| 43 | 35 | Female | 7 | Democrat | Yes | Yes | Yes |
| 44 | 25 | Female | 4 | Independent | Yes | Yes | Yes |
| 45 | 33 | Male | 2 | Independent | Yes | Yes | No |
| 46 | 32 | Female | 4 | Independent | Yes | No | No |
| 47 | 29 | Female | 0 | Independent | No | No | No |
| 48 | 37 | Female | 6 | Independent | Yes | Yes | No |
| 49 | 33 | Female | 6 | Democrat | Yes | Yes | No |
| 50 | 66 | Male | 2 | Republican | Yes | Yes | Yes |
In: Statistics and Probability
def isPower(x, y):
"""
>>> isPower(4, 64)
3
>>> isPower(5, 81)
-1
>>> isPower(7, 16807)
5
"""
# --- YOU CODE STARTS HERE
def isPower(x, y):
num = x
count = 1
while x < y:
x *= num
count += 1
if x == y:
return count
return -1
def translate(translation, txt):
"""
>>> myDict = {'up': 'down', 'down': 'up', 'left': 'right', 'right': 'left', '1': 'one'}
>>> text = 'Up down left Right forward 1 time'
>>> translate(myDict, text)
'down up right left forward one time'
"""
# --- YOU CODE STARTS HERE
def translate(translationDict, txt):
words = txt.lower().split()
for i in range(len(words)):
if words[i] in translationDict:
words[i] = translationDict[words[i]]
return ' '.join(words)
def onlyTwo(x, y, z):
"""
>>> onlyTwo(1, 2, 3)
13
>>> onlyTwo(3, 3, 2)
18
>>> onlyTwo(5, 5, 5)
50
"""
# --- YOU CODE STARTS HERE
def onlyTwo(x, y, z):
m1 = max(x, y, z)
m2 = (x + y + z) - min(x, y, z) - m1
return m1 * m1 + m2 * m2
def largeFactor(num):
"""
>>> largeFactor(15)
5
>>> largeFactor(24)
12
>>> largeFactor(7)
1
"""
# --- YOU CODE STARTS HERE
def largeFactor(num):
n = num - 1
while n >= 1:
if num % n == 0:
return n
n -= 1
def hailstone(num):
"""
>>> hailstone(5)
[5, 16, 8, 4, 2, 1]
>>> hailstone(6)
[6, 3, 10, 5, 16, 8, 4, 2, 1]
"""
# --- YOU CODE STARTS HERE
def hailstone(num):
result = []
while num > 1:
result.append(num)
if num % 2 == 0:
num = num // 2
else:
num = 3 * num + 1
result.append(num)
return result
if any wrong with my code
In: Computer Science
1. Find the equation of the line with slope of m = −" # and through the point (8,−1).Write your final answer in slope -intercept form. ______________________________
2. Find the equation of the line through the points (2,−7) ??? (−4,−8 ). Write your final answer in slope intercept form. ______________________________
3. Find the equation of the line which passes through the point (10,−3) & is perpendicular to the line 5?+3?=2 ______________________________
In: Math
Consider a Cournot duopoly, the firms face an (inverse) demand function: Pb = 128 - 3 Qb. The marginal cost for firm 1 is given by mc1 = 4 Q. The marginal cost for firm 2 is given by mc2 = 6 Q. (Assume firm 1 has a fixed cost of $ 65 and firm 2 has a fixed cost of $ 87 .) How much profit will firm 2 earn in the duopoly equilibrium ?
In: Economics
1) How many photons are emitted during a transition from a higher level orbit to a lower level orbit? a)1 b)2 c)3 d)4
2) True/False? An electron can transition from any allowed orbit to any other allowed orbit.
3) What is the wavelength of light emitted when an electron drops from the 3 to the 2 shell in a hydrogen atom?
In: Chemistry