Email is becoming one of the most common forms of communication in the workplace. Although email is a main form of business communication, it is not always done well. Many employers complain of employees who send poorly written and confusing emails. Because of their extensive use, it is important to learn how to write emails professionally with informative subject lines, appropriate greetings, well-organized bodies, and complete closing information.
This assignment will allow you the opportunity to practice composing professionally written emails. The following Word document contains several job-related scenarios which require an email to be sent. Read each scenario and compose an appropriate email by applying the concepts discussed in the lesson. Be sure to analyze your audience, implement a you-attitude, and use positive emphasis.
Compose all your emails in the same document but write each each email on a page of its own
Include an informative subject line for each email
Include an appropriate greeting for each email
Include a formal closing for each email
The following are work-related scenarios which require an email to be sent. Read each scenario and compose an appropriate email by applying the concepts discussed in the lesson. Be sure to analyze your audience, implement a you-attitude, and use positive emphasis. Use a new page for each email.
Include an informative subject line
Include an appropriate greeting
Include a formal closing
Scenario 1:
You applied for a financial analyst job two weeks ago at the Acme Loan Company and haven’t heard back from the supervisor Mr. Hiram. You’ve been holding your breath and want to check in to get a status on if you’re going to get hired or not. Send a professional email to Mr. Hiram inquiring about the job.
Scenario 2:
You’ve been offered a job as a Branch Manager at Madden Incorporated and have determined that you do not want to accept it because you received a better offer elsewhere. Send a professional email to the supervisor, Ms. Eldridge, to turn down the position.
Scenario 3:
You’re working on a proposal for a new policy at work with your co-worker Marc. Your boss has given you a strict deadline which you are not on track of meeting because Marc is overcomplicating the process and it is slowing the entire project down. Write a casual but professional email to Marc expressing some ideas you want to share to simplify the process and work more efficiently to stay on the timeline.
Scenario 4:
You and your co-worker Dana are constantly having conflict in the office and it is affecting your ability to get your job done. You have made efforts to try to mend things be she is convinced she is not part of the problem. Now you have to get your boss Mrs. Freelander involved. Write a professional and tactful email to Mrs. Freelander asking her to meet with you so you can discuss with her what has been going on and ask her to step in to assist with the situation.
Scenario 5:
Your co-worker Ted has asked you to serve on a departmental planning committee at your job which is going to take up a lot of time you don’t have. You’re already running behind on the last project he assigned to you. Write Ted a professional email informing him that you will not be able to serve on the committee because you don’t want to overcommit.
Scenario 6:
You work in the customer relations department at a retail store. You have a customer who ordered some holiday gift baskets which were damaged on their way from the warehouse to the store due to an exceptionally turbulent flight. Write a professional email to the customer explaining the situation and ensuring them you are doing everything you can to deliver their order before the holiday. Try to maintain the relationship with the customer as much as possible.
In: Operations Management
COP2271 MATLAB HW9 Homework: Modified Vigenere Cipher Implement a decryption cipher to decode messages using a secret key. You are required to submit the solution and screenshots for this question. Key programming concepts: if statements, loops, strings Approximate lines of code: 27 (does not include comments or white space) Commands you can’t use: None... Program Inputs • Enter message to decrypt: • Enter secret key: – The user will always enter text for all prompts, no error checking needed. The secret key will always be lower case to start. Program Outputs • Updated key: XXX – Replace XXX with the adjusted secret key • Decrypted msg: YYY – Replace YYY with the deciphered message Assignment Details This assignment will give you a brief introduction into cryptography using a modified Vigenere Cipher! Cryptography allows us to encode and decode messages that are difficult to decipher without knowledge of a secret key/table/rules. Cryptography is a rich subject in its own right, and we will not have time to cover it in detail. Please check out the numerous online resources if you want more information: http://www.braingle.com/brainteasers/codes/index.php This particular cipher depends upon a secret key (a single word) selected by the user that only contains letters which is paired with a phrase. For example, given the phrase: Attack Now! the user could choose the secret key: woot The first step to encryption is to repeat the letters in secret key until it has the same amount of letters as the message, skipping any spaces or punctuation! So with woot as the key, repeat the letters w, o, o, t for each letter in Attack Now!. Note that you must also change the letters in the key to upper case if the letters in phrase are upper case. COP2271 MATLAB HW9 A t t a c k N o w ! W o o t w o O t w ! Now each letter in the secret message determines how far to shift the corresponding letter in the updated key. Essentially, take the position in the alphabet (starting from 0) of the letters in message and then shift key by that amount (like a Caesar Cipher). Also, treat upper case and lower case letters as two different alphabets. Here is a detailed breakdown: Letter in message Alphabet position Letter in key Decrypted letter A 0 W W t 19 o h t 19 o h a 0 t t c 2 w y k 10 o y N 13 O B o 14 t h w 22 w s ! ! Following this table, Attack Now! becomes Whhtyy Bhs!. To decode this message for the homework, do the reverse of this process! Sample Output The following test cases do not cover all possible scenarios (develop your own!) but should indicate if your code is on the right track. To guarantee full credit, your program’s output should exactly match the output below. Test Case 1: Enter message to decrypt: Whhtyy Bhs! Enter secret key: woot Updated key: Wootwo Otw! Decrypted msg: Attack Now! COP2271 MATLAB HW9 Test Case 2: Enter message to decrypt: Rr pathf! Enter secret key: edna Updated key: Ed naedn! Decrypted msg: No capes! Test Case 3: Enter message to decrypt: Qmh frisll kr pfbapgehleu! Enter secret key: syndrome Updated key: Syn dromes yn dromesyndro! Decrypted msg: You caught me monologuing! Test Case 4: Enter message to decrypt: Kbsm urm lhrrfdr uzwcxb! Enter secret key: rusty Updated key: Rust yru styrust yrusty! Decrypted msg: That was totally wicked! Test Case 5: Enter message to decrypt: Hbgzy’k xs ucjwc mwqn? Enter secret key: lucius Updated key: Luciu’s lu ciusl uciu? Decrypted msg: Where’s my super suit?
In: Computer Science
.data
A: .space 80 # create integer array with 20 elements ( A[20] )
size_prompt: .asciiz "Enter array size [between 1 and 20]: "
array_prompt: .asciiz "A["
sorted_array_prompt: .asciiz "Sorted A["
close_bracket: .asciiz "] = "
search_prompt: .asciiz "Enter search value: "
not_found: .asciiz " not in sorted A"
newline: .asciiz "\n"
.text
main:
# ----------------------------------------------------------------------------------
# Do not modify
la $s0, A # store address of array A in $s0
add $s1, $0, $0 # create variable "size" ($s1) and set to 0
add $s2, $0, $0 # create search variable "v" ($s2) and set to 0
add $t0, $0, $0 # create variable "i" ($t0) and set to 0
addi $v0, $0, 4 # system call (4) to print string
la $a0, size_prompt # put string memory address in register $a0
syscall # print string
addi $v0, $0, 5 # system call (5) to get integer from user and store in register $v0
syscall # get user input for variable "size"
add $s1, $0, $v0 # copy to register $s1, b/c we'll reuse $v0
prompt_loop:
# ----------------------------------------------------------------------------------
slt $t1, $t0, $s1 # if( i < size ) $t1 = 1 (true), else $t1 = 0 (false)
beq $t1, $0, end_prompt_loop
sll $t2, $t0, 2 # multiply i * 4 (4-byte word offset)
addi $v0, $0, 4 # print "A["
la $a0, array_prompt
syscall
addi $v0, $0, 1 # print value of i (in base-10)
add $a0, $0, $t0
syscall
addi $v0, $0, 4 # print "] = "
la $a0, close_bracket
syscall
addi $v0, $0, 5 # get input from user and store in $v0
syscall
add $t3, $s0, $t2 # A[i] = address of A + ( i * 4 )
sw $v0, 0($t3) # A[i] = $v0
addi $t0, $t0, 1 # i = i + 1
j prompt_loop # jump to beginning of loop
# ----------------------------------------------------------------------------------
end_prompt_loop:
addi $v0, $0, 4 # print "Enter search value: "
la $a0, search_prompt
syscall
addi $v0, $0, 5 # system call (5) to get integer from user and store in register $v0
syscall # get user input for variable "v"
add $s2, $0, $v0 # copy to register $s2, b/c we'll reuse $v0
# ----------------------------------------------------------------------------------
# TODO: PART 1
# Translate C code into MIPS (bubble sort)
# The above code has already created array A and A[0] to A[size-1] have been
# entered by the user. After the bubble sort has been completed, the values im
# A are sorted in increasing order, i.e. A[0] holds the smallest value and
# A[size -1] holds the largest value.
#
# int t = 0;
#
# for ( int i=0; i<size-1; i++ ) {
# for ( int j=0; j<size-1-i; j++ ) {
# if ( A[j] > A[j+1] ) {
# t = A[j+1];
# A[j+1] = A[j];
# A[j] = t;
# }
# }
# }
#
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# TODO: PART 2
# Translate C code into MIPS (binary search)
# The array A has already been sorted by your code above int PART 1, where A[0]
# holds the smallest value and A[size -1] holds the largest value, and v holds
# the search value entered by the user
#
# int left = 0;
# int right = size - 1;
# int middle = 0;
# int element_index = -1;
#
# while ( left <= right ) {
#
# middle = left + (right - left) / 2;
#
# if ( A[middle] == v) {
# element_index = middle;
# break;
# }
#
# if ( A[middle] < v )
# left = middle + 1;
# else
# right = middle - 1;
#
# }
#
# if ( element_index < 0 )
# printf( "%d not in sorted A\n", v );
# else
# printf( "Sorted A[%d] = %d\n", element_index, v );
#
# ----------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------
# Do not modify the exit
# ----------------------------------------------------------------------------------
exit:
addi $v0, $0, 10 # system call (10) exits the progra
syscall # exit the program
In: Computer Science
Chapter 14: Video Quiz - Luke's Lobster
Video Transcript:
>> What are you doing there?
>> Put the roll on the butter wheel.
>> In 2009, near the height of the recession, 27-year-old Luke Holden took a risk; he opened a lobster sandwich shop in New York City.
>> We're a young, hardworking team that does -- has never had a lot of resources and we like doing things with our hands. It's enabled us to grow during hard times.
>> To make it work, Holden held onto his day job at a bank and spent nights and weekends serving $14 lobster rolls from a less than 300 square foot storefront.
>> I love doing this, you know, we've got a great team around us.
>> A few months later, shunning traditional forms of advertising, he put Luke's Lobster's campaign online. Holden teamed up with a new tech startup called Foursquare. If I'm somebody who's never heard of Twitter, never heard of a mobile application, is a little bit confused what even a smart phone is, how would you describe what you're doing?
>> Forget about paper, forget about carrying coupons around, that loyalty card, booklet or any one of these things that you get in the mail, we're trying to make it so that it's a little bit more digital into the more virtual like this digital wallet that you're carrying around, that's constantly rewarding you as you go around and explore your city.
>> Foursquare is a mobile application that allows its 10 million users to virtually check in from their smart phone when they visit a local business like Luke's. The information is then shared with everyone in the individual's social network.
>> Word of mouth from your friends is stronger than I think any other form of advertisement in my opinion.
>> The information is also shared with the business where someone's checking in so a company knows exactly who its customers are.
>> And then we're also helping local merchants connect with the people that are most likely to become, you know, really great customers with those and through that, we're allowing businesses to, you know, offer discounts and specials to a lot of these local merchants.
>> So you just checked in to Luke's.
>> Yes.
>> And how many times have you been here this week?
>> Probably twice this week but according to Foursquare, I think I'm like at 107 visits now.
>> 107 in how much time?
>> Over -- a bit over a year.
>> Virtual customer loyalty with a very real impact on businesses like Luke's. Do you think it's possible to do business as an entrepreneur now without using these social tools, social media?
>> I think it's possible but I don't think it's smart. If someone takes the time to do some type of action outside or inside of your restaurant that doesn't involve buying food at the counter, then that action should be recognized
please answer these multiple choice questions correctly:
1)Which of the following is NOT a reason that Luke’s Lobster uses FourSquare and other social media platforms?
To develop and use its own promotion department
To learn about customers likes and dislikes
To polish a brand image
To develop and promote new products
To create a community feeling
2)FourSquare is best described as a
crowdsourcing platform.
social media community.
social game.
social content site.
blog.
3)Of all the social media tools available, for Luke’s Lobster, one of the most important aspects of FourSquare is
blogs.
ratings.
hashtags.
games.
podcasts.
4)Luke’s Lobster uses social media technologies, channels, and software to create, communicate, deliver, and exchange offerings that have value; this is called
social media marketing.
crowdsourcing.
social media research.
inbound marketing.
social content marketing.
***please please please gave me correct answers for these question. because i always get wrong answer, when i asked here.
In: Operations Management
Trina’s Trinkets Inc. (Trina’s) is a corporation incorporated and headquartered in Orem, Utah. Trina’s sells more than 3,600 different types of small trinkets and gifts, primarily to the end consumer, but also to wholesalers.
Trina’s has operated in Utah for the past 15 years. The company made a strategic decision to target expansion of its sales into specific geographic regions outside of Utah as well. This helps encourage word-of-mouth advertising, which reduces the costs of general advertising expenses. To that end, Trina’s is now selling in several nearby states, including Arizona, Idaho, Montana, Washington and Wyoming. Trina’s plans to expand further throughout the western United States in the coming years.
The founder, Trina, comes from rural Utah and has worked to increase opportunities in rural areas by building her manufacturing and warehousing facilities in the city of Ephraim in Sanpete County, Utah. Since Trina’s established its operations in Ephraim, both the city and county have grown significantly and the area is now considered urban.
Trina’s uses catalogs, phone calls and sales calls to make sales, but does not yet sell online. Trina’s ships all goods from Ephraim, Utah, using a third-party carrier (e.g., UPS, FedEx).[1]Trina’s only sells non-food items and does not offer services.
To handle customer inquiries, Trina’s opened a small call center in rural Riverton, Wyoming, three years ago. The call center employs eight people who help take orders, solve customer issues and take care of phone solicitations from small businesses. Trina chose Wyoming for the call center because she has extended family in the area and wanted to provide work opportunities for them.
In 2017, Trina’s began a pilot program in which salespeople are sent to several states to try and increase sales at larger businesses that buy Trina’s products and then resell them. To date, Trina’s has sent salespeople to Utah, Montana and Washington. This pilot program appears to be successful. In the coming years, Trina’s hopes to expand the program to all of the states in which she currently sells products and then she plans to reach several new markets.
Margins are slim for this business, ranging from 5% to 15% of sales before state sales taxes are determined. The industry is extremely competitive and Trina’s faces competition from many online companies that are not required to pay state sales tax. Because of the high competition (which is different than most companies), Trina’s does not feel that it can increase prices to collect sales tax, and instead sales taxes come out of the margins.
Given the tight margins and relatively high costs to manufacture in the United States, Trina is considering moving some of her manufacturing to Mexico and then purchasing warehouse space in Arizona. She has also considered trying to sell her products through Amazon.com. She continues to consider how her operations can positively impact rural areas.
Trina’s has struggled to compute sales taxes correctly for each jurisdiction. Trina’s hired you, a tax advisor, to answer a variety of sales-tax-related questions and create a system (or tool) to compute sales taxes for the business. Additionally, Trina is interested to know how the potential operational changes she is considering would affect her sales tax collection obligations.
For purposes of this case, you can ignore sales tax issues related to the shipping costs.
In: Accounting
ANALYSING A SPREADSHEET AND PRESENTING A BUSINESS REPORT
Case Study
Pink Lady Apple Orchard is a small family run orchard in Red Hill, Victoria. Jacinta and Pete own the property, which includes 50 hectares of apple plantings.
As the market price of apples sold to supermarkets and fruit shops has decreased in the past few years, causing business to stagnate, Pete and Jacinta have decided to use some of their apple supply to produce their own range of apple based products.
They have set up a small market stall at the orchard where they sell products directly to the public. They also have a regular stand at local markets. The number of customers is growing as word of mouth spreads. In an effort to further expand they have negotiated with a number of small retailers to stock their products. Recently they also employed a systems developer, who set up a website which enables them to market their products online and sell directly to the public.
In a further effort to expand sales Jacinta organised to have their products advertised on a number of ‘shopping deal’ sites. Each site charged an upfront fee of $500.00. The Pink Lady Apple Orchard’s ‘deal was advertised throughout February. The orchard offered 30% off any sale made through the deal site. After deducting a further 5% commission on sales the ‘deal’ site passed the order and the payment onto the organisation. Jacinta then processed the order and delivered the products to the customer. Jacinta hoped that by offering this deal more customers would be attracted to their products.
Jacinta and Pete have always delivered goods free of charge to their wholesale customers. However, with increased sales they are concerned about the increased courier charges. Pete has decided that by charging 15% delivery charge on each retail order he can recoup all the delivery charges.
As Jacinta and Pete are already busy attending to the apple orchard they have employed Ruby, a local resident, two mornings a week (8 hours) to attend to all online orders.
Although the number of orders is increasing, Jacinta is concerned that maybe not all products sell well enough to continue production. She has been experimenting with different flavours and products, including a new recipe for “Spicy Apple Chips”. Maybe she should change products or delete some products. She does not want unwanted stock accumulating in the storage sheds. She believes that the ‘special deals’ she has advertised for January/February will certainly help sales, but is concerned that she has made a bad decision with regard to profitability.
Jacinta has set up a spreadsheet. She has asked you to complete any relevant calculations and to use excel ‘tools’ to analyse the data she has given you. She then requires you to provide a business report with regards to the effectiveness of the recently implemented online ordering system, and in particular both the overall popularity and profitability of their products and the success of the recent ‘deals’ campaigns. After analysing the relevant data she wants you to consider the options with regard to future sales and to alert her to other factors that need to be considered before a final decision can be made. She is interested in reading your recommendations with regard to online sales.
PREPARING THE BUSINESS REPORT
Report Content
The analysis, findings and recommendations which you prepare for Jacinta and Pete should be outlined in a professional business report.
This report should include:
1) A brief Introductionthat outlines clearly the purpose of the report.
2) A brief presentation of theanalysis you have carried out and a discussion regarding the resultsof this analysis
3)A discussion regarding the results of your analysis.
Identification/discussion regarding other factors that may need to be considered before a final decision can be made.
4)A short concluding summaryof the content of the report.
5)Finally, at least two clear recommendationsthat Jacinta and Pete can adopt. These recommendations must be drawn from the analysis that you have carried out, and must have been discussed in the body of your report.
In: Operations Management
Molly’s Home Cooking, a regional restaurant with locations in three small Southern towns, one of which is a college town, specializes in comfort foods and regional specialties. Two of the restaurants have been open for over five years. The Molly’s located in the college town opened in May 2018. The restaurants are either freestanding near other businesses or in a strip shopping/eating area. With a menu consisting of all fresh, cooked-to-order foods, Molly’s features different items daily and serves traditional Southern desserts. Some of the menu items include meatloaf, turkey cranberry salad, specialty sandwiches, salad options, barbecued beef, and fresh pecan pie. While open for lunch and dinner daily, Molly’s also offers breakfast, featuring homemade biscuits, on weekends. On the drink menu, customers will find tea, coffee, soda, and water. A couple of beers and wines are on the menu, but Molly’s does not want to be thought of as a bar. The restaurant also caters special events such as weddings and business lunches and sells boxed meals (barbecue) that feed four to six people for outdoor events such as tailgates.
Menu items are reasonably priced, but are more expensive than many fast food restaurants, while less expensive than most “sit down” restaurants. Each restaurant has the same setup, where customers place and pay for their orders at the front counter and then get glasses for drinks. They fill their own drinks and get their silverware and napkins at the back of the restaurant. Customers select their own tables and servers bring food to the table. If ordered, desserts are brought to the table at the end of the meal so that it may be served hot and with ice cream or whipped cream, if preferred. Customers may add desserts at the end of the meal and pay at the counter when finished eating. If customers prefer take-out orders, they may call in advance and pick up the order. Servers let them know how long it will take for the order to be ready.
Prior to opening a restaurant, the owners have a week of “test and training” days where they invite people from local communities for lunch or dinner. For example, they may offer local businesspeople a free lunch or invite owners from other surrounding businesses to bring their families. For the Molly’s in the college town, the owners and employees extended lunch invitations to several faculty, staff, and students and asked them each to invite a few guests. Molly’s wants to introduce members from each target market to the delicious foods on their menus. Not only does this strategy generate brand awareness, but it also creates word-of-mouth and positive public relations.
With regard to promotion, Molly’s Home Cooking, like many other small businesses, has a limited promotion budget. They use social media, primarily Facebook, where they promote daily specials. For the restaurant located in the college town (about a mile from campus), Molly’s placed an advertisement in the university’s student newspaper early in the fall semester. They also placed signs in front of the restaurant to attract visitors.
Molly’s has many repeat customers at each established restaurant. Those restaurants also attract consumers who are traveling or sightseeing in nearby areas. The newest Molly’s in the college town opened right before the majority of students went home for summer internships. Many faculty do not teach in the summer, so the town becomes very quiet during the summer months. Molly’s Home Cooking wants to increase awareness, get more repeat customers, and increase profits.
For Molly’s Home Cooking in the college town, what promotion strategies do you recommend to attract faculty, staff, and students from the university?
Without spending much on promotion or changing menu prices, how can Molly’s generate loyal customers in established markets and in the college town?
Other than running one ad in the student newspaper, Molly’s has the same setup, menus, prices, and promotion (Facebook page) in each market. Given that Molly’s has a very limited budget, should the restaurant change anything for different target markets (e.g., travelers, families, local businesses, college population)?
In: Operations Management
Mary Barra started working at General Motors when she was a teenage intern in 1980. She started on the factory floor as an inspector. She held many jobs across GM, including executive assistant, head of internal communications, executive director of North American vehicle operations, VP of Global HRM, Senior VP for Global Product Development, and finally, in 2014 CEO.
When she took over as CEO at General Motors, Mary Barra surprised people when she began the process of transforming GM not by starting at the top and developing a new strategic plan per se. Rather, she focused on foundational issues designed to help transform GM’s culture. She focused on simple but important changes such as the company’s dress policy. As you learned in this chapter, organizational culture is made up of rituals, stories, and routines. It is something you can “feel” within an organization. Some scholars refer to it as a company’s “secret sauce.” Part of any new employee’s adjustment process includes learning their new organization’s culture. However, culture change is especially challenging. How people dress is an important signal to an organization’s culture.
After Barra changed the 10-page dress code to two simple words (which were “Dress Appropriately”), she had to problem-solve with leaders throughout the organization. As she asked herself, “if they cannot handle ‘dress appropriately,’ what other decision can't they handle? And I realized that often, if you have a lot of overly prescriptive policies and procedures, people will live down to them.” Thus, her focus on simplifying the dress code helped her see where the resistance to doing things in a new way might come from and how to overcome such concerns when it came to bigger decisions such as which parts of the business to retain or sell off.
Her philosophy is that everyone is better off if they stop making assumptions about what other people want or need. She also asked GM employees to try new things. For example, to encourage teams at GM to work together, she asked 250 engineers and designers to participate in a paper sailboat race. As John Calabrese, GM’s VP of Global Engineering puts it, “She wanted them to have fun at a highly stressful time, but also encourage teamwork and collaboration.” She made other changes in the culture as evidenced by the phrases heard at GM. The idea of “customer first” is not unique for a company such as Amazon but for GM, it was something new. She has also put data from customers at the center of product development as well as manufacturing decisions.
Barra states, “You can’t fake culture. You’ve got to have an environment where people feel engaged, where they’re working on things that are important and they have an opportunity to have career development… I want to create the right environment and that’s what we’re working on.” While Barra’s approach is different from past CEOs, the approach appears to be paying off. GM’s stock price was under $28 per share as a low in 2014. In 2018, it was trading at over $44 a share.
1)How do you think simplifying the dress code can contribute to the process of culture change?
2) Is having a very simple, two-word dress code empowering or ambiguous, or both? What do you see as the reasons for your response?
3)Thinking about different industries, which do you think are most suited for this type of policy? Which might be most suited? Please explain your rationale for each.
4) What do you think Mary Barra means when she says ‘You can’t fake culture”?
5)Do you think Mary Barra is well-positioned to change the company culture, given her long tenure at GM? Why or why not?
Please help. Thanks
In: Operations Management
Step 1: Capturing the input
The first step is to write a functionGetInput()that inputs the expression from the keyboard and returns the tokens---the operands and operators---in a queue. You must write this function.
To make the input easier to process, the operands and operators will be separated by one or more spaces, and the expression will be followed by #. For example, here’s a valid input to your program:
6 4 15 * – #
Back in Codio, modify “main.cpp” by defining the following function above main(). Note the additional #include statements, add those as well:
#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;
queue<string> GetInput()
{
queue<string> Q;
stringtoken;
cin >> token;
.. // TODO: loop andinputrestof expression, adding to queue. // Do not add the sentinel # to the queue..
return Q;
}
Now modify the main() function to call GetInput, and change the cout statement to output the size of the queue returned by GetInput. This is a simple check to make sure the queue contains the elements of the expression. Build and run, and enter an expression such as
6 4 15 * – #
The output should be a size of 5---3 operands and 2 operators (the # should not be stored in the queue). If you want to be sure the queue is correct, write a quick loop to pop the contents of the queue one by one, and output. When you’re done, comment out these debug output statements.
Step 2: Evaluating the expression (assuming valid input)
Now that the input has been captured, step 2 is to evaluate the expression. The idea is simple: when you see an operand (an integer), push it on a stack. When you see an operator, pop off two operands, perform the operation, and push on the result. When the input has been processed, the answer is on top of the stack. Go ahead and draw out an example on paper and convince yourself it works: 6 4 15 * - should yield -54.
Write a function EvaluatePostfix that takes a queue containing the input, and returns two values: the integer result, and true / false(denoting valid input or not). Here’s the function definition:
bool EvaluatePostfix(queue<string> input, int& result)
{
stack<int> operands;
.. // evaluate expression:.
result = operands.top(); // answer is on top
return true; // successful evaluation
}
For now, assume valid input, and don’t bother with error checking.Loop until the queue is empty, popping one token at a time. Since the tokens are strings, and a string is an array of characters, you can access the first element of a string using[0]. This makes it easy to tell if a token is an integer operand:
string s = input.front();// next token in the queue:
input.pop();
if (isdigit(s[0]))// integer operand:
{
operands.push(stoi(s));// in C++, usestoito convert string to int
}
else // operator{
...
}
To determine the operator, compare s[0] to ‘+’, ‘*’, etc. Once you have the function written, modify main() to call the function and output the result. Build, run and test with a variety of expressions. Here’s a few:
6 4 15 * – # => -54
6 4 –5 * # => 10
21 10 30 * + 80 / # => 4
Step 3: Handling invalid input
The last step is to extend the program to handle invalid input. Modify the EvaluatePostfix function to handle the following:
1. What if the stack contains more than one value at the end (or is empty)? This can happen when the input is empty, or the expression doesn’t contain enough operators. Example: 1 2 3 + #. In this case EvaluatePostfix should return false.
2. What if the stack does not contain 2 operands when an operator is encountered? This can happen when the expression doesn’t contain enough operands. Example: 1 2 + + #. In this case EvaluatePostfix should return false.
3. What if the operator is something other than +,-, * or /. In that case, EvaluatePostfix should return false.
You’ll need to modify main() to check the value returned by EvaluatePostfix. If false is returned, output the word “invalid” followed by a newline. Build, run and test.
In: Computer Science
IS 633 Assignment 1
Due 9/27
Please submit SQL statements as a plain text file (.txt). If blackboard rejects txt file you can submit a zipped file containing the text file. Word, PDF, or Image format are not accepted. You do not need to show screen shot. Make sure you have tested your SQL statements in Oracle 11g.
Problem 1. Please create the following tables for a tool rental database with appropriate primary keys & foreign keys. [30 points]
Assumptions:
The list of tables is:
Tables:
Cust Table:
cid, -- customer id
cname, --- customer name
cphone, --- customer phone
cemail, --- customer email
Category table:
ctid, --- category id
ctname, --- category name
parent, --- parent category id since category has a hierarchy structure, power washers, electric power washers, gas power washers. You can assume that there are only two levels.
Tool:
tid, --- tool id
tname, --- tool name
ctid, --- category id, the bottom level.
quantity, --- number of this tools
Time_unit table allowed renting unit
tuid, --- time unit id
len, --- length of period, can be 1 hour, 1 day, etc.
min_len, --- minimal #of time unit, e.g., hourly rental but minimal 4 hours.
Tool_Price:
tid, --- tool id
tuid, --- time unit id
price, -- price per period
Rental:
rid, --- rental id
cid, --- customer id
tid, --- tool id
tuid, --- time unit id
num_unit, --- number of time unit of rental, e.g., if num_unit = 5 and unit is hourly, it means 5 hours.
start_time, -- rental start time
end_time, --- suppose rental end_time
return_time, --- time to return the tool
credit_card, --- credit card number
total, --- total charge
Problem 2. Insert at least three rows of data to each table. Make sure you keep the primary key and foreign key constraints. [20 points]
Problem 3. Please write ONE SQL statement for each of the following tasks using tables created in Problem 1. You can ONLY use conditions listed in the task description. Task 1 and 2 each has 5 points. Tasks 3 to 6 each has 10 points. [50 points]
Task 1: return IDs of rentals started in August 2019.
Hint: function trunc(x) converts x which is of timestamp type into date type.
Task 2: Return names and quantity of all tools under the category carpet cleaner. You can assume there is no subcategory under carpet cleaner
Task 3: return number of rentals per customer along with customer ID in the year 2019 (i.e., the start_time of the rental is in 2019).
Task 4: return IDs of tools that has been rented at least twice in 2019.
Task 5: return the price of renting a small carpet cleaner (the name of the tool) for 5 hours.
Hint: find unit price for hourly rental and then multiply that by 5.
Task 6: return names of customers who have rented at least twice in year 2019 (i.e., rental’s start time is in 2019).
In: Computer Science