what are the strongest arguments for the proposition that corporations should have influence on how public policy is formulated?
In: Operations Management
3 Design
3.1 Token Class
The Token type, which is an enum type and used in the Token class, is defined as follows:
enum Token_type {ID, INT, OP, EQ, OpenBrace, CloseBrace, INVALID};
If string s, passed in to the constructor or set method, is an identifier then the token type is ID; is a nonnegative integer then the token type is INT; is one of +, -, *, / then the token type is OP; is = then the token type is EQ; is (, open parenthesis, then the token type is OpenBrace; is ), close parenthesis, then the token type is CloseBrace; is none of the above then the token type is INVALID. The constructor and set method are required to figure out the type of a token string.
Token class is used to store a “token”, which has three members and a few member functions. The members are:
type This field stores the type of the token. Its type is Token type whose definition is given earlier.
token This field stores the token. Its type is string.
priority This field stores the priority of the token when token is
an operator
or a parenthesis. Its type is int. The member functions are:
Token() This default constructor initializes type to INVALID, token to empty string, and priority to -1.
Token(string s) This constructor takes in a string and treats it as a token. It sets the type and token member accordingly. For the current project, it sets the priority member to -1.
void set(string s) This method takes in a string and treats it as a token. It sets the members based on the new token s. Again, for the current project, it sets the priority member to -1.
2
int value() const This method returns the value associated with the token when token type is integer or identifier. In this assignment, if the type is INT, the integer represented as a string stored in token member should be converted to int and returned; if the type is ID, it returns -1; for all other types, it returns -2.
In the future assignment, we will be able to process assignment statement such as x=5 and a symbol table is used to associate x with 5. In this case, for token x, the function returns 5.
void display() const This method outputs the values of the token members in three lines. Each line begins with the member name, followed by “=”, followed by the value. This method is mainly for debugging use. For example, if token string is a12, we have:
type = ID token = a12 (value is -1) priority = -1
Token type get type() const Getter for type member. string get
token() const Getter for token member.
int get priority() const Getter for priority member.
Typically during the tokenizing process of the input string, we get a sequence of characters stored in a string, which is a token. We then use Token class via its constructor or set method to figure out if the token is valid or not and what type of token it is and so on. That is perhaps the most challenging programming (algorithmic) task for the implementation of the Token class. Since an expression is really a sequence of tokens in an abstract sense, the Token class is used by the Expression class to be designed next.
Since none of the member of the Token class involves pointer type and mem- ory allocation, the default copy constructor and assignment operator provided by the compiler should work just fine. We do not need to implement them.
3.2 Expression Class
The Exp type type, which is an enum type and used in the Expression class, is defined as follows:
enum Exp_type {ASSIGNMENT, ARITHMETIC, ILLEGAL};
For the current assignment, we are not required to figure out the type of an expression. We will do that in a later assignment. For the current project, we treat an expression in two ways: 1) as a string and 2) as a sequence of tokens (Token objects stored in a vector) obtained from the string.
Expression class is used to store an “expression”, which has five members and a few member functions. The members are:
3
original This field stores the original or not yet processed “expression”. Its type is string.
tokenized This field stores the expression as a sequence of tokens. Its type is vector.
postfix This field stores the expression as a sequence of tokens in postfix nota- tion provided the expression has arithmetic type. Its type is vector. This member is not used for the current homework assignment but will be used for the last assignment. The set method or con- structors of this assignment should leave it as an empty vector, that is to do nothing.
valid This field indicates whether the expression is a valid expression (no syntax error). Its type is bool. It is not used for the current homework assignment but will be used for the last assignment. The set method or constructors of this assignment should simply set it to false.
type This field indicates whether the type of the expression is ASSIGNMENT or ARITHMETIC expression or ILLEGAL. Its type is Exp type. It is not used for the current homework assignment but will be used for the last assignment. The set method or constructors of this assignment should simply set it to ILLEGAL.
The member functions are:
Expression() This default constructor initializes all fields to empty or false or ILLEGAL.
Expression(const string& s) This constructor takes in a string and treats it as an expression. It tokenizes the input string and sets the original and tokenized members accordingly. And it sets the other members based on the description given earlier (refer to each member description).
void set(const string& s) This method takes in a string and treats it as an expression. It tokenizes the input string and sets the original and tok- enized members accordingly. And it sets the other members based on the description given earlier.
void display() const This method output the values of the expression fields, one field per line. This method is mainly for debugging use.
original=a12=1?ab + -a0123c(a+123)*(ab-(3+4 )) tokenized =
a12;=;1?ab;+;-;a;0123;c;(;a;+;12;3;);*;(;ab;-;(;3;+;4;);); number
of tokens = 24
postfix =
valid = false type = ILLEGAL
4
string get original() const Getter for original member.
vector get tokenized() const Getter for tokenized member.
other methods There are other methods such as to evaluate the expression, to transform the expression, and getters for other fields such as postfix, valid, or type. These methods will be needed for the last assignment. Since we have not studied the related concepts and algorithms, these member functions are omitted.
When we receive a string (maybe from a line of input or a hard coded value within the program), which would be an expression, we use Expression class to figure out if the expression is legal or not and what its type is and so on (use either the non default constructor or set method, and pass the string as its argument).
In order to do the above, the string (perhaps a line of input from the user) gets tokenized first by the Expression class via its constructor or set method. That is perhaps the most challenging programming (algorithmic) task for the current implementation of the Expression class.
Since none of the member of the Expression class involves pointer type and memory allocation, the default copy constructor and assignment operator pro- vided by the compiler should work just fine. We do not need to implement them.
4 Implementation
Please note the similarity between the constructor that takes a string parameter and the set method in Token class. We could implement the set method first. Then the constructor calls the set method to accomplish its tasks. The same can be said for the similarity between the non default constructor and set method in Expression class.
You should implement and test the Token class first. Then use it in the development of the Expresion class. The most challenging method to implement (develop the code for) is the set method of the Expression class. We need to figure out the right algorithm to tokenize. One of the reasons is that we cannot simply use space (a blank character) as a delimiter to tokenize. For instance, in (2+3)*4, we have 7 valid tokens. They are (, 2, +, 3, ), *, 4 and no space betweenthem. Butifitisgivenas( 2 + 3 ) * 4,wecouldusespace. Our method should work for any possible combination of spaces and tokens. You might first assume space is used to separate each token including special tokens and develop a solution. Then consider if you might add space to the given string to use your with space as delimiter solution earlier. This approach is perhaps less efficient than those algorithms that process the string once because it processes a string twice and might double its length. However, it is acceptable for this assignment.
5
For those students who would like a challenge, you might develop an efficient algorithm that tokenizes the string with one pass through the given string.
Token class implementation has .h and .cpp files and the same is true for Expression class. The homework3.cpp file contains the code for testing of both classes.
5 Test and evaluation
Have a main program to test the Token class by sending the constructor and set method many different “tokens” and display the results to see if they are correct or not. You may want to be creative and cover a wide range of possible “tokens” in your testing. Similarly, test the Expression class by sending the constructor and set method many different “expressions” and display the results to see if they are correct or not. You may want to be creative and cover a wide range of possible “expressions” in your testing.
In: Computer Science
Organizational Behavior & Mgmt
Discussion Question:
Are all managers leaders at the same time? Why? and Are all leaders managers at the same time? Why?
In: Operations Management
A fox fleeing from a hunter encounters a 0.675 m tall fence and attempts to jump it. The fox jumps with an initial velocity of 7.50 m/s at an angle of 45.0°, beginning the jump 1.94 m from the fence. By how much does the fox clear the fence? Treat the fox as a particle.
In: Physics
Complete the following Pharmacotherapy and Medication Assisted Therapy chart. For each "Purpose of Medication," list the name of a medication that is used for the purpose listed. Complete each of the remaining fields for the medication listed.
Anxiety and depression |
|||||
Detoxification of substances |
|||||
Decrease cravings |
In: Psychology
Particle A and particle B are held together with a compressed spring between them. When they are released, the spring pushes them apart and they then fly off in opposite directions, free of the spring. The mass of A is 5.00 times the mass of B, and the energy stored in the spring was 30 J. Assume that the spring has negligible mass and that all its stored energy is transferred to the particles. Once that transfer is complete, what are the kinetic energies of (a) particle A and (b) particle B?
In: Physics
In: Psychology
DO THIS IN C# (PSEUDOCODE)Social Security Payout. If you’re taking this course, chances are that you’re going to make a pretty good salary – especially 3 to 5 years after you graduate. When you look at your paycheck, one of the taxes you pay is called Social Security. In simplest terms, it’s a way to pay into a system and receive money back when you retire (and the longer you work and the higher your salary, the higher your monthly benefit). Interestingly, your employer will pay the same amount for you. The current tax rate is 6.2% until you make approximately $132,900. For this assignment, we’re going to help out hourly employees. Design (pseudocode) and implement (source code) a program that asks users how much they make per hour, the number of hours they work per week, and calculates the yearly income. For the second half, the program should calculate and display the amount of Social Security tax the user will pay for that year. You must write and use at least two functions in addition to the main function. At least one function must not have a void return type. Note, don’t forget to put the keywords “public” and “static” in front of your functions. Document your code and properly label the input prompt and the outputs as shown below.
Sample run 1: Enter hourly wage: 10 Enter your hours per week: 40 You will earn $20800.0 per year You will pay $1591.2 in Social Security tax Sample run 2: Enter hourly wage: 40 Enter your hours per week: 60 You will earn $124800.0 per year You will pay $9547.2 in Social Security tax
In: Computer Science
For the division method for creating hash functions,
map a key k into one of m slots by taking the remainder of k divided by m. The hash function is:
h(k) = k mod m,
where m should not be a power of 2.
For the Multiplication method for creating hash functions,
The hash function is h(k) = └ m(kA –└ k A ┘) ┘ = └ m(k A mod 1) ┘
where “k A mod 1” means the fractional part of k A; and a constant A in the range
0 < A < 1.
An advantage of the multiplication method is that the value of m is not critical.
Choose m = 2p for some integer p.
Give your explanations for the following questions:
(1) why m should not be a power of 2 in the division method for creating hash function; and
(2) why m = 2p, for some integer p, could be (and in fact, favorably) used.
In: Computer Science
SA Adventures Unlimited was formed four years ago, by Michael
and Jill Rodriguez. Michael was a trained geologist, while Jill had
a master’s degree in Spanish. They were both avid outdoor
enthusiasts and fell in love while trekking across the Andes in
Chile. Upon graduation, they seized upon the idea of starting their
own specialized tour business that would focus on organizing and
leading “high-end” adventure trips in South America. Their first
trip was a three-week excursion across Ecuador and Peru. The trip
was a resounding success, and they became convinced that they could
make a livelihood doing something they both enjoyed.
After the first year, Adventures Unlimited began to slowly expand
the size and scope of the business. The Rodriguezes’ strategy was a
simple one. They recruited experienced, reliable people who shared
their passion for South America and the outdoors. They helped these
people organize specific trips and advertised the excursion over
the Internet and in travel magazines.
Adventures Unlimited has grown from offering 4 trips a year to
having 16 different excursions scheduled, including trips to
Central America. They now have an administrative support staff of
three people and a relatively stable group of five trip
planners/guides whom they hired on a trip-by-trip contract basis.
The company enjoyed a high level of repeat business and often used
their customers’ suggestions to organize future trips.
Although the Rodriguezes were pleased with the success of their
venture, they were beginning to encounter problems that worried
them about the future. A couple of the tours went over budget
because of unanticipated costs, which eroded that year’s profit. In
one case, they had to refund 30 percent of the tour fee because a
group was stranded five days in Blanco Puente after missing a train
connection. They were also having a hard time maintaining the high
level of customer satisfaction to which they were accustomed.
Customers were beginning to complain about the quality of the
accommodations and the price of the tours. One group,
unfortunately, was struck by a bad case of food poisoning. Finally,
the Rodriguezes were having a hard time tracking costs across
projects and typically did not know how well they did until after
their taxes were prepared. This made it difficult to plan future
excursions.
The Rodriguezes shared these concerns around the family dinner
table. Among the members in attendance was Michael’s younger
brother, Mario, a student at a nearby university. After dinner,
Mario approached Michael and Jill and suggested that they look into
what business people called “project management.” He had been
briefly exposed to project management in his Business Operations
class and felt that it might apply to their tour business.
Case Question
1. To what extent does project management apply to Adventures
Unlimited?
2. What kind of training in project management should the
Rodriguezes, the administrative staff,
and tour guides receive to improve the operation of Adventures
Unlimited?
3. Identify major topics or skill sets that should be
addressed.
In: Operations Management
In: Economics
Using CARDTRONICS,
Create the Final Strategic Plan. The Final Strategic Plan contains the elements of all the previous weeks' components and incorporates instructor feedback. The strategic recommendations will be evaluated and the best options chosen for recommendation. The final strategic plan should contain:
Create a 10- to 15-slide Microsoft® PowerPoint® presentation with visuals and speaker notes to present the strategic plan, summarizing all relevant elements from previous weeks. The objective is to sell the strategic plan to investors or company directors.
Format the assignment according to APA guidelines.
In: Operations Management
which of the following is NOT true regarding inventory cost behavior as the replenishment quantity increases?
A. ordering cost decreases
B. Order cost increases
C. the # of exposures to stockout decrease
D. the holding cost increases
E. stockout cost decreases
Which of the following is true regarding manufacturing organizations' use of inventory?
A. A firm that experiences highly seasonal demand, yet produces at a constant rate, uses inventory to absorb the swings in demand.
B. A firm Amy experience constant demand, yet have seasonal production.
C. Consolidation of items stored will typically yield more favorable transportation rates.
D. warehousing and material handling can contribute significantly to distribution costs.
E. All of the above
The Newsboy Problem is:
A. a system with repetitive order quantities and instantaneous replenishment.
B. suitable for products with long life cycles
C. a system with repetitive order quantities and non-instantaneous replenishment
D. Suitable for products with a short life cycle or one-time order
Which of the following is a reason to hold inventory?
A. increase costs due to economies of scale in production
B. increase costs in purchasing and transportation
C. increase customer service
D. increase uncertainties in demand and lead times
E. none of the above
For Push vs. Pull inventory control, which of the following is true?
A. a pull system tends to optimize efficiency of the whole supply chain
B. a push system is controlled by the multiple warehouses that receive goods from a single plant
C.A pull system optimizes the warehouses but does not necessarily optimize the whole supply chain
D. A push system will always result in more inventory than a pull system
E. all of the above
In: Operations Management
In stock market crash, What were the major differences between the 1920s and the 1930s? How did the end of WWI affect the U.S. economy? Explain the relationship between Liberty Bonds, “Investing Culture”, Margin Buying, and the rapid appreciation of stock values in the 1920s? Why did the major bankers meet at J.P Morgan’s office across the street from the NYSE? What did they subsequently do? How did the “Liquidity Crisis” compound an even greater contraction in GDP after stock prices collapsed? What means did Roosevelt implement to help stabilize stock markets immediately and long-term? What effects did the Great Depression have internationally? Do you see any parallels today?
In: Economics
11. A business rule says that an employee cannot earn more than
his/her manager.
Assume that each employee row has a foreign key which refers to a
manger row.
a. Can this business rule be implemented using a fixed format
constraint?
b. Can this business rule be implemented using a trigger?
12. Triggers should be created sparingly. Why?
13. Should you use a trigger to check the uniqueness of a primary
key?
14. What is a Distributed Database system?
15. What advantages does a Distributed Database have over a
Centralized Database?
16. Why do some users require data from multiple sites in a
Distributed Database?
17. What is Horizontal Fragmentation within a DDBMS?
Note: Questions are based on DBMS (Distributed database and triggers)
In: Computer Science