Questions
6.30 LAB*: Program: Authoring assistant (1) Prompt the user to enter a string of their choosing....

6.30 LAB*: Program: Authoring assistant (1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! (2) Implement a print_menu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option and the sample text string (which can be edited inside the print_menu() function). Each option is represented by a single character. If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement the Quit menu option before implementing other options. Call print_menu() in the main section of your code. Continue to call print_menu() until the user enters q to Quit. (3 pts) Ex: MENU c - Number of non-whitespace characters w - Number of words f - Fix capitalization r - Replace punctuation s - Shorten spaces q - Quit Choose an option: (3) Implement the get_num_of_non_WS_characters() function. get_num_of_non_WS_characters() has a string parameter and returns the number of characters in the string, excluding all whitespace. Call get_num_of_non_WS_characters() in the print_menu() function. (4 pts) Ex: Number of non-whitespace characters: 181 (4) Implement the get_num_of_words() function. get_num_of_words() has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call get_num_of_words() in the print_menu() function. (3 pts) Ex: Number of words: 35 (5) Implement the fix_capitalization() function. fix_capitalization() has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. fix_capitalization() also returns the number of letters that have been capitalized. Call fix_capitalization() in the print_menu() function, and then output the the edited string followed by the number of letters capitalized. Hint 1: Look up and use Python functions .islower() and .upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string. (3 pts) Ex: Number of letters capitalized: 3 Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! (6) Implement the replace_punctuation() function. replace_punctuation() has a string parameter and two keyword argument parameters exclamation_count and semicolon_count. replace_punctuation() updates the string by replacing each exclamation point (!) character with a period (.) and each semicolon (;) character with a comma (,). replace_punctuation() also counts the number of times each character is replaced and outputs those counts. Lastly, replace_punctuation() returns the updated string. Call replace_punctuation() in the print_menu() function, and then output the edited string. (3 pts) Ex: Punctuation replaced exclamation_count: 1 semicolon_count: 2 Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here, our hopes and our journeys continue. (7) Implement the shorten_space() function. shorten_space() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shorten_space() returns the string. Call shorten_space() in the print_menu() function, and then output the edited string. Hint: Look up and use Python function .isspace(). (3 pt) Ex: Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!

Python Please!

In: Computer Science

Prompt: Review and respond to the three questions presented in the “The ‘People’ Focus: Human Resources...

  • Prompt: Review and respond to the three questions presented in the “The ‘People’ Focus: Human Resources at Alaska Airlines” case at the end of Chapter 10.
  • Requirements: A 250-word minimum, APA compliant paper addressing all three questions. Regarding Question 2 – is there a biblical basis for employee empowerment? The final section is to include an analysis of how you see the approaches stated either aligning with or going counter to Scripture. How do Genesis 1:26-27 and 1 Peter 5:2-3 apply to this case?

The “People” Focus: Human Resources at Alaska Airlines

With thousands of employees spread across nearly 100 locations in the United States, Mexico, and Canada, building a committed and cohesive workforce is a challenge. Yet Alaska Airlines is making it work. The company’s “people” focus states:

While airplanes and technology enable us to do what we do, we recognize this is fundamentally a people business, and our future depends on how we work together to win in this extremely competitive environment. As we grow, we want to strengthen our small company feel . . . We will succeed where others fail because of our pride and passion, and because of the way we treat our customers, our suppliers and partners, and each other.

Managerial excellence requires a committed workforce. Alaska Airlines’ pledge of respect for people is one of the key elements of a world-class operation.

Effective organizations require talented, committed, and trained personnel. Alaska Airlines conducts comprehensive training at all levels. Its “Flight Path” leadership training for all 10,000 employees is now being followed by “Gear Up” training for 800 front-line managers. In addition, training programs have been developed for Lean and Six Sigma as well as for the unique requirements for pilots, flight attendants, baggage, and ramp personnel. Because the company only hires pilots into first officer positions—the right seat in the cockpit, it offers a program called the “Fourth Stripe” to train for promotion into the captain’s seat on the left side, along with all the additional responsibility that entails (see exterior and interior photos of one of Alaska Airlines’ flight simulators on the opening page of this chapter).

Customer service agents receive specific training on the company’s “Empowerment Toolkit.” Like the Ritz-Carlton’s famous customer service philosophy, agents have the option of awarding customers hotel and meal vouchers or frequent flier miles when the customer has experienced a service problem.

Because many managers are cross-trained in operational duties outside the scope of their daily positions, they have the ability to pitch in to ensure that customer-oriented processes go smoothly. Even John Ladner, Director of Seattle Airport Operations, who is a fully licensed pilot, has left his desk to cover a flight at the last minute for a sick colleague.

Along with providing development and training at all levels, managers recognize that inherent personal traits can make a huge difference. For example, when flight attendants are hired, the ones who are still engaged, smiling, and fresh at the end of a very long interview day are the ones Alaska wants on the team. Why? The job requires these behaviors and attitudes to fit with the Alaska Airlines team—and smiling and friendly flight attendants are particularly important at the end of a long flight.

Visual workplace tools also complement and close the loop that matches training to performance. Alaska Airlines makes full use of color-coded graphs and charts to report performance against key metrics to employees. Twenty top managers gather weekly in an operations leadership meeting, run by Executive VP of Operations, Ben Minicucci, to review activity consolidated into visual summaries. Key metrics are color-coded and posted prominently in every work area.

Alaska’s training approach results in empowered employees who are willing to assume added responsibility and accept the unknowns that come with that added responsibility.

Discussion Questions*

  1. Summarize Alaska Airlines’ human resources focus in your own words.
  2. Why is employee empowerment useful to companies such as Alaska Airlines?
  3. What tools discussed in the chapter might be employed to enhance the company’s training and performance efforts? Why?

In: Operations Management

Journal Entries and Trial Balance Elite Realty acts as an agent in buying, selling, renting, and...

Journal Entries and Trial Balance

Elite Realty acts as an agent in buying, selling, renting, and managing real estate. The unadjusted trial balance on March 31, 2018, follows:

Elite Realty
Unadjusted Trial Balance
March 31, 2018
Account
No.
Debit
Balances
Credit
Balances
11 Cash 10,910
12 Accounts Receivable 25,420
13 Prepaid Insurance 1,240
14 Office Supplies 740
16 Land
21 Accounts Payable 7,190
22 Unearned Rent
23 Notes Payable
31 Common Stock 10,000
32 Retained Earnings 13,600
33 Dividends 870
41 Fees Earned 123,990
51 Salary and Commission Expense 92,040
52 Rent Expense 12,400
53 Advertising Expense 7,320
54 Automobile Expense 2,230
59 Miscellaneous Expense 1,610
154,780 154,780

The following business transactions were completed by Elite Realty during April 2018:

Apr. 1. Paid rent on office for month, $4,220.
2. Purchased office supplies on account, $1,100.
5. Paid annual insurance premiums, $3,040.
10. Received cash from clients on account, $21,100.
15. Purchased land for a future building site for $76,000, paying $8,400 in cash
and giving a note payable for the remainder.
17. Paid creditors on account, $3,800.
20. Returned a portion of the office supplies purchased on November 2, receiving
full credit for their cost, $170.
23. Paid advertising expense, $1,690.
27. Discovered an error in computing a commission; received cash from the salesperson
for the overpayment, $840.
28. Paid automobile expense (including rental charges for an automobile), $1,270.
29. Paid miscellaneous expenses, $380.
30. Recorded revenue earned and billed to clients during the month, $25,320.
30. Paid salaries and commissions for the month, $6,520.
30. Paid dividends, $840.
30. Rented land purchased on November 15 to local merchants association for
use as a parking lot in December and January, during a street rebuilding program;
received advance payment of $2,530.

Required:

Use the attached spreadsheet to complete parts 1 and 3. Click on the Spreadsheet icon to open and save the Excel file to your computer. Your input into the spreadsheet will not be included in your grade in CengageNOW on this problem.

1. Enter the April 1, 2018, balance of each account in the appropriate balance column of a four-column account. The word Balance has been entered in the item section and a check mark (√) has been placed in the Posting Reference column.

2. Journalize and insert the Posting References for the transactions for April in a two-column journal beginning on Page 18. For a compound transaction, if an amount box does not require an entry, leave it blank.

General Journal Page 18
Date Description Post. Ref. Debit Credit
2018
Apr. 1
Apr. 2
Apr. 5
Apr. 10
Apr. 15
Apr. 17
Apr. 20
Apr. 23


General Journal Page 19
Date Description Post. Ref. Debit Credit
2018
Apr. 27
Apr. 28
Apr. 29
Apr. 30-Rev.
Apr. 30-Salary
Apr. 30-Dividends
Apr. 30-Rent

3. Post to the ledger, extending the account balance to the appropriate balance column after each posting.

4. Using the balances from the spreadsheet, prepare an unadjusted trial balance of the ledger as of April 30, 2018. List all accounts in the order of Assets, Liabilities, Stockholders’ equity, Revenues, and Expenses. If an amount box does not require an entry, leave it blank.

Elite Realty
Unadjusted Trial Balance
April 30, 2018
Account
No.
Debit Balances Credit Balances

5a. Assume that the April 30 transaction for salaries and commissions should have been $5,620. As a result, the unadjusted trial balance in (4) would  

5b. Assume that the April 30 transaction for salaries and commissions should have been $5,620. Journalize the correcting entry. If an amount box does not require an entry, leave it blank.

General Journal PAGE 19
Date Description Post. Ref. Debit Credit
2018
Apr. 30

5c. Assume that the November 30 transaction for salaries and commissions should have been $5,620. Is this error a transposition or slide?

In: Accounting

Requirement: Create your own e-commerce business in Saudi Arabia (website or mobile application), you need to...

Requirement:

Create your own e-commerce business in Saudi Arabia (website or mobile application), you need to explain the process that you will follow in building your e-commerce presence.

Before you begin to build a website or app of your own, there are some important questions you will need to think about and answer. The answers to these questions will drive the development and implementation of your e-commerce presence.

Set up Your E-Commerce Presence

  • What is the idea? (the visioning process)
  • Introduce your e-commerce business.
    • Provide an overview of your business idea
  • Product and type of services.
    • What are the different types of products? Explain
    • What kinds of services are provided by your online store? [ customer service, exchange and return, delivery and payment options] Explain
  • Business statement.
  • Business vision.
  • Business objective.
  • Where’s the money:
    • What is the company’s business model?
    • Give a general idea of how your business will generate revenues
  • Who and where is the target audience? Explain demographics, lifestyle, consumption patterns, etc.
  • What is the ballpark? Characterize the marketplace. - Size, growth, demographics, structure.
  • Where’s the content coming from?
  • Know yourself— conduct a SWOT analysis for your business.
  • Develop an e-commerce presence map.
  • Develop a timeline: Milestones. - 6 phases.
  • How much will this cost?

Building an E-Commerce Site: A Systematic Approach

  • Planning: The Systems Development Life Cycle
  • Systems analysis/planning
  • Business objectives. What are the capabilities you want your site to have?
  • System functionalities (Shopping cart, payment system …. etc.)
  • Information requirements (Dynamic text and graphics catalog … etc.)
  • Systems design
  • (Logical and Physical)
  • How it will look likes in terms of design and format
  • Building the system (a simple website layout)
  • Create your own website using wix.com www.wix.com
  • Or you can design the layout using any free e-commerce website template.
  • Include 2-4 screenshots of your site
  • Testing (What type of testing will be applied?)
  • Implementation

Choosing Software

The development of e-commerce required a great deal more interactive functionality, such as the ability to respond to user input (name and address forms), take customer orders for goods and services, clear credit card transactions on the fly, consult price and product databases, and even adjust advertising on the screen based on user characteristics.

    • Functionality for web server
    • Provides basic functionality for sales
  • Online catalogue
  • Shopping cart
  • Credit card processing

Explain the different software you need for your site functionality.

Choosing Hardware

  • Underlying computing equipment needed for e-commerce functionality
  • Right-Sizing Your Hardware Platform: The Demand Side and the Supply Side
  • Explain the different hardware needed for your site or app.

Payment and Security

  • What are the methods of payment you are going to use in your online store and why?
  • What are the commonly used technologies to secure your online transactions?
  • Develop a privacy policy. The policy should outline how information will be collected and used?

Categorize marketing and advertising strategy and method.

  • Explain the online, offline and social media marketing strategies you will use to bring people to your website? And why?

Explain your business e-commerce process

  • Explain in detail all the steps from the time a visit is recorded until the final user buys a product.

Conclude your report.

Guidelines for the assignment:

  • Make sure to include the cover page with all information required.
  • This is group project, which is part from your course score. It requires effort, search and critical thinking.
  • Use font Times New Roman, Calibri or Arial.
  • Use 1.5 or double line spacing with left Justify all paragraphs.
  • Use the footer function to insert page number.
  • Ensure that you follow the APA style in your project and references.

Your project report length should be between 2200 to 2500 words.

*****please notice that the due date is in 3 hours i need it to be solved as soon as possible*****

*** please i need new idea and fully, unique, new answers reword it using your own word not the same posted ones here on chegg i need it to be complete on the write way its worth 15 marks ****

*the answer must be unique not copied "plagiarized "

In: Operations Management

INSTRUCTIONS: READ THE FOLLOWING SITUATION AND ANSWER THE QUESTIONS ARISING FOR THE CASE ANALYSIS. “STONYFIELD FARM...

INSTRUCTIONS: READ THE FOLLOWING SITUATION AND ANSWER THE QUESTIONS ARISING FOR THE CASE ANALYSIS.

“STONYFIELD FARM GOES TO THE BLOGS”

The Stonyfield Farm story is a kind of legend. In 1983, friends and social activists Gary Hirschberg and Samuel Kaymen started with a good yogurt recipe, seven cows, and a dream. They established an organic yogurt company in Wilton, New Hampshire, to take advantage of baby boomers' growing concerns about natural foods and health, and to revitalize the dairy industry in New England. Stonyfield Farms has grown to become the third largest organic company in the world, with annual sales of more than $ 50 million in 50 states. It produces more than 18 million glasses of yogurt each month.

Stonyfield Farrn's spectacular growth is attributable in part to its ability to offer a product to a special niche market - people who value healthy food and want to protect the environment. These values ​​have become part of the "personality" of the company. Stonyfleld promises to use only natural ingredients and milk that has not been produced with antibiotics, synthetic growth hormones, or pesticides or toxic fertilizers. The company donates 10 percent of its profits each year to projects that help protect or restore the planet.

As the company expanded, management feared that it might lose touch with its loyal and committed customer base. Advertising based on traditional media was expensive and did not really help the company to "connect" with the kind of people it was trying to reach. This company prefers word-of-mouth techniques that deliver its message to customers in ways more compatible with its popular, organic, and activist-friendly image.

Stonyfield has multiple active email newsletters with more than 500,000 subscribers, and typically posts messages promoting causes that he supports on the tops of his yogurt glasses. Now she's turning to blogging to further personalize her customer relationships and reach even more people. Inspired by Howard Dean's presidential campaign and Dean's blogger tutorials, CEO Hirschberg became convinced that Stonyfield could use blogging to create a more personal relationship with consumers, different from the traditional sales relationship. "Blogs give us what we call a handshake with consumers" and "a little more access to us

Stonyfield now publishes two separate blogs on his website — Baby Babble and Bovine Bugle. At one time Stonyfield was running five blogs, but decided to withdraw three of them because they weren't attracting enough readers. Baby Babble provides a forum for Stonyfield employees and other parents of young children to meet and discuss child development and balance work with the family. Stonyfield created that blog because baby yogurts are one of its most popular product lines, and parenting blogs seem to appeal to a large number of readers. The Bovine Bugle provides reports about Jonathan's Organic Dairy Farm. Gates in Franklin, Vermont, a member of the organic cooperative that supplies milk for Stonyfield products.
This blog sparks a large number of nostalgic comments from readers who remember their childhood on a farm. As organic food grows in importance, these blogs help the company showcase the aspects that make it different from other brands and invite customers to help them in this endeavor. Stonyfield continually posts new content to each of the blogs. Readers can subscribe to any of them and automatically receive updates when available. And of course they can reply to these posts.
The benefits of blogging for Stonyfield have not yet been quantified so far, but management is confident there are real benefits. Blogs have created a positive response for the Stonyfield brand by providing readers with something that inspires them or sparks their interest -If blogs give new information to readers, inspire them to protect the environment or ask them for opinions, the administration believes that They will remember the brand when they are in front of the yogurt shelves in the supermarket or grocery store and that they will take a Stonyfleld product instead of a competitor when it is time to choose. Stonyfield has a fairly large website. Blogs offer a way to highlight some of the content on the Web that would otherwise be lost. This, too, helps drive some blog readers to buy Stonyfield products.
1.What is Stonyfield farm's e-commerce model and business strategy? What challenges and problems does the company face?

In: Operations Management

INSTRUCTIONS: READ THE FOLLOWING SITUATION AND ANSWER THE QUESTIONS ARISING FOR THE CASE ANALYSIS. “STONYFIELD FARM...

INSTRUCTIONS: READ THE FOLLOWING SITUATION AND ANSWER THE QUESTIONS ARISING FOR THE CASE ANALYSIS.

“STONYFIELD FARM GOES TO THE BLOGS”

The Stonyfield Farm story is a kind of legend. In 1983, friends and social activists Gary Hirschberg and Samuel Kaymen started with a good yogurt recipe, seven cows, and a dream. They established an organic yogurt company in Wilton, New Hampshire, to take advantage of baby boomers' growing concerns about natural foods and health, and to revitalize the dairy industry in New England. Stonyfield Farms has grown to become the third largest organic company in the world, with annual sales of more than $ 50 million in 50 states. It produces more than 18 million glasses of yogurt each month.

Stonyfield Farrn's spectacular growth is attributable in part to its ability to offer a product to a special niche market - people who value healthy food and want to protect the environment. These values ​​have become part of the "personality" of the company. Stonyfleld promises to use only natural ingredients and milk that has not been produced with antibiotics, synthetic growth hormones, or pesticides or toxic fertilizers. The company donates 10 percent of its profits each year to projects that help protect or restore the planet.

As the company expanded, management feared that it might lose touch with its loyal and committed customer base. Advertising based on traditional media was expensive and did not really help the company to "connect" with the kind of people it was trying to reach. This company prefers word-of-mouth techniques that deliver its message to customers in ways more compatible with its popular, organic, and activist-friendly image.

Stonyfield has multiple active email newsletters with more than 500,000 subscribers, and typically posts messages promoting causes that he supports on the tops of his yogurt glasses. Now she's turning to blogging to further personalize her customer relationships and reach even more people. Inspired by Howard Dean's presidential campaign and Dean's blogger tutorials, CEO Hirschberg became convinced that Stonyfield could use blogging to create a more personal relationship with consumers, different from the traditional sales relationship. "Blogs give us what we call a handshake with consumers" and "a little more access to us

Stonyfield now publishes two separate blogs on his website — Baby Babble and Bovine Bugle. At one time Stonyfield was running five blogs, but decided to withdraw three of them because they weren't attracting enough readers. Baby Babble provides a forum for Stonyfield employees and other parents of young children to meet and discuss child development and balance work with the family. Stonyfield created that blog because baby yogurts are one of its most popular product lines, and parenting blogs seem to appeal to a large number of readers. The Bovine Bugle provides reports about Jonathan's Organic Dairy Farm. Gates in Franklin, Vermont, a member of the organic cooperative that supplies milk for Stonyfield products.
This blog sparks a large number of nostalgic comments from readers who remember their childhood on a farm. As organic food grows in importance, these blogs help the company showcase the aspects that make it different from other brands and invite customers to help them in this endeavor. Stonyfield continually posts new content to each of the blogs. Readers can subscribe to any of them and automatically receive updates when available. And of course they can reply to these posts.
The benefits of blogging for Stonyfield have not yet been quantified so far, but management is confident there are real benefits. Blogs have created a positive response for the Stonyfield brand by providing readers with something that inspires them or sparks their interest -If blogs give new information to readers, inspire them to protect the environment or ask them for opinions, the administration believes that They will remember the brand when they are in front of the yogurt shelves in the supermarket or grocery store and that they will take a Stonyfleld product instead of a competitor when it is time to choose. Stonyfield has a fairly large website. Blogs offer a way to highlight some of the content on the Web that would otherwise be lost. This, too, helps drive some blog readers to buy Stonyfield products.
III. Is the strategy of using "blog" one that provides a competitive advantage to the company? Explain your answer. What are the advantages and disadvantages of using blogs for a company like this?

In: Operations Management

using python/IDLE (1) Prompt the user to enter a string of their choosing. Store the text...

using python/IDLE

(1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt)

Ex:

Enter a sample text:
we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!

You entered: we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!


(2) Implement a print_menu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option and the sample text string (which can be edited inside the print_menu() function). Each option is represented by a single character.

If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement the Quit menu option before implementing other options. Call print_menu() in the main section of your code. Continue to call print_menu() until the user enters q to Quit. (3 pts)

Ex:

MENU
c - Number of non-whitespace characters
w - Number of words
f - Fix capitalization
r - Replace punctuation
s - Shorten spaces
q - Quit

Choose an option:


(3) Implement the get_num_of_non_WS_characters() function. get_num_of_non_WS_characters() has a string parameter and returns the number of characters in the string, excluding all whitespace. Call get_num_of_non_WS_characters() in the print_menu() function. (4 pts)

Ex:

Number of non-whitespace characters: 181


(4) Implement the get_num_of_words() function. get_num_of_words() has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call get_num_of_words() in the print_menu() function. (3 pts)

Ex:

Number of words: 35


(5) Implement the fix_capitalization() function. fix_capitalization() has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. fix_capitalization() also returns the number of letters that have been capitalized. Call fix_capitalization() in the print_menu() function, and then output the the edited string followed by the number of letters capitalized. Hint 1: Look up and use Python functions .islower() and .upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string. (3 pts)

Ex:

Number of letters capitalized: 3
Edited text: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!


(6) Implement the replace_punctuation() function. replace_punctuation() has a string parameter and two keyword argument parameters exclamation_count and semicolon_count. replace_punctuation() updates the string by replacing each exclamation point (!) character with a period (.) and each semicolon (;) character with a comma (,). replace_punctuation() also counts the number of times each character is replaced and outputs those counts. Lastly, replace_punctuation() returns the updated string. Call replace_punctuation() in the print_menu() function, and then output the edited string. (3 pts)

Ex:

Punctuation replaced
exclamation_count: 1
semicolon_count: 2
Edited text: we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  nothing ends here,  our hopes and our journeys continue.


(7) Implement the shorten_space() function. shorten_space() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shorten_space() returns the string. Call shorten_space() in the print_menu() function, and then output the edited string. Hint: Look up and use Python function .isspace(). (3 pt)

Ex:

Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!

In: Computer Science

Mr. Kent doesn't care about almost anything ... but himself and his money. So, when his...

Mr. Kent doesn't care about almost anything ... but himself and his money. So, when his power plant leaked radioactive goo that caused several species of wildlife to go extinct, he was only concerned with the public perception as it might affect his income and possible jail time.

Many rumors surfaced around the Springfield Nuclear Power Plant. One of them is high concern over the mutation rate of the rare Springfield molted platypus. With barely more than 500 left in the wild, the word "extinction" has been tossed around. So, to quell the media, Mr. Kent had 30 of them captured, dissected, and analyzed to check for signs of mutation. He found that the mutation rate is 2% each month, but when they do mutate, they become sterile and cannot reproduce. With this information, he wants to create one of those newfangled computer simulations that the press loves so much. That's where you come in!

Specifications:

In this assignment, you will create a class called Animal_Category.

Your Animal_Category class is to contain the following data members:

  • A string for appearance ( hair/fur/scale/feathers)
  • a bool for nurse (true/false)
  • a bool for cold_blooded (true/false)
  • a bool for live_on_land (true/false)
  • a bool for live_in_water (true/false)

Your Animal_Category class is to contain the following member functions:

  • a constructor with arguments
  • a print function

You will also create a class called Platypus. Below, we will describe what will define a platypus. You will also create a main function in which you will create objects of type platypus to test the functionality of your new user-defined type.

Your Platypus class is to contain the following data members:

  • a static int for platypus_count (to increment upon creation of a new platypus and decrement upon destruction of a platypus)
  • a float for weight
  • an int for age (months)
  • a string for name
  • a char for gender
  • a bool to indicate whether alive (or not)
  • a bool to indicate whether mutant (or not)
  • an Animal_Category for animal_type
  • a constant mutation rate that is 2%

Member functions:

  • a constructor with no arguments that creates a dead platypus
  • a constructor that you can pass values to so as to establish its gender, weight, age, and name; it will default to alive and not mutant.
  • a constant print function that will output to the screen the attributes of that platypus in a nice, easy to read format.
  • an age_me function that returns nothing but increments the object's age. It will also calculate the chance that the object will become a mutant and when needed changes the value of the corresponding data member (remember that the mutation rate is 2% each month and it should become 100% for the platypus to become mutant).

Further, the platypus has a chance of becoming dead each time it ages. This chance is ten times the platypus' weight. A 5 pound platypus has a 50% chance of death. A 10 pound platypus (or heavier) has a 100% chance of death. Again here update the value of the corresponding data member when needed.

  • a fight function that accepts another platypus object as a parameter. It will have the calling platypus attack the other (passed in) platypus. The survivor is based on a "fight ratio": it is calculated as (calling_platypus_weight/other_platypus_weight) * 50. A random value from 1 to 100 is generated. If it is less than the fight ratio, the calling platypus survives; otherwise the other platypus survives. You must to be able to have a statement like p1.fight(p2).print() (where p1 and p2 are objects of this class)
  • an eat function that increases the weight of the platypus by a random amount from 0.1% to 5.0% of the platypus' current weight.
  • A friend hatch function that will randomly set up a newborn platypus with alive=true, mutant=false, and age=0. Gender will randomly be 'm' or 'f' with equal probability. Weight will randomly be between 0.1 and 1.0 pounds. Name will default to “plipo”.

Think very carefully about writing the above functions and how they should be used. There are indeed circumstances when some functions should not execute. For example, a dead platypus shouldn't eat anything.

Your program should fully test your platypus class. It must call every member function in the platypus class. It must print to the screen what it is doing and show the changes that appear when the member functions are called. The fight function will require two platypuses: one to call the fight function and one to be a parameter in the fight function.

c++ language

In: Computer Science

JAVA PROGRAMMING For this assignment, review the successor method in BST. The successor of a node...

JAVA PROGRAMMING

For this assignment, review the successor method in BST. The successor of a node is the node with the next highest value in the tree. The successor of the node with the largest value in a tree, is null.

The algorithm to find the successor of a node is straight forward: if the node has a right subtree, the successor is the smallest node in that subtree (for that we use method minNode). Otherwise, we traverse the tree from the root and towards the node whose successor we are seeking. Each node at which we continue to traverse left, we mark as the successor. The last such node is the actual successor.

TreeNode with parent node

Modify BST so that each TreeNode has a pointer to its parent node. (The only node without a parent is the root node). Ensure that every time you add a node to a tree, that all points (left, right, and parent) are updated as needed.

Successor search using the parent node

Write a new method, with signature

TreeNode successorP(TreeNode ofThisNode) that finds the successor of a node without traversing the tree from the root, but by using the knowledge captured in the parent field. There are many variants of this technique online. Many of them are incomplete or may contain bugs. Make sure that your code works perfectly well with each node in the test tree sycamore. Your code must be well documented with meaningful comments.

Delete a node

Write a method with signature

boolean deleteNode(TreeNode deleteMe)
that implements the deletion algorithm as discussed in class. The deletion algorithm is as follows:

If node-to-delete has zero children, just dereference it from its parent.

If node-to-delete has one child only, its child is "adopted" by its parent.

If the node-to-delete has two children, swap it with its successor, reducing the case to one of the previous two.

For this problem, use the parent field in TreeNode.

import java.util.ArrayList;
import java.util.List;

/**
 * A simple Binary Search Tree (BST) class.
 */
public class BST {

    // A tree is just a root, really! Everything grows from here.
    private TreeNode root; // what's a TreeNode? See below.

    // And here's what a TreeNode looks like.
    class TreeNode {
        String value; // The data we store in this node
        TreeNode left; // left child
        TreeNode right; // right child
        // basic constructor
        public TreeNode(String s) {
            this.value = s; // assigns content to String
            left = right = null; // makes pointers to children null
        } // constructor TreeNode
    } // class TreeNode


    /**
     * Inserts unique value into tree; if value already
     * exists, method returns false.
     *
     * @param s value to insert
     */
    public boolean insert(String s) {
        boolean success = false;
        if (!valueExists(s)) { // Value is not stored in tree already; we can add it
            success = true; // Method will return this value to indicate successful insertion
            TreeNode newNode = new TreeNode(s); // Node with new value to be inserted
            if (root == null) { // If tree is empty,
                root = newNode; // new node becomes its root.
            } else { // Start our search from the root to find where to place new node.
                TreeNode currentNode = root; // We start our search from the root.
                boolean keepTrying = true; // Control variable from the principal loop, below.
                while (keepTrying) {  // Principal loop; exits only when keepTrying becomes false.
                    if (s.compareTo(currentNode.value) > 0) { // New value is greater than current node; go RIGHT
                        if (currentNode.right == null) { // If right child is null
                            currentNode.right = newNode; // place new value here
                            keepTrying = false; // Flag to exit the principal loop.
                        } else { // Right child is not null
                            currentNode = currentNode.right; // Make right child the current node and try again.
                        }
                    } else { // New value is less than current node; go LEFT
                        if (currentNode.left == null) { // If left child is null
                            currentNode.left = newNode; // place new value here.
                            keepTrying = false; // Flag to exit the principal loop.
                        } else { // Left child is not null.
                            currentNode = currentNode.left; // Make left child the current node and try again.
                        }
                    }
                }
            }
        }
        return success;
    } // method insert

    /**
     * Find if String searchForMe exists in the tree, in an iterative scan
     *
     * @param searchForMe Value to search for
     * @return true if searchForMe found; false otherwise
     */
    public boolean valueExists(String searchForMe) {
        boolean success = false; // Assume String is not in the tree.
        if (root != null) { // Start searching from the top.
            TreeNode currentNode = root; // initialize iterative node
            boolean keepTrying = true; // Loop control flag
            while (keepTrying) {
                if (currentNode.value.compareTo(searchForMe) == 0) { // found!
                    success = true; // flag success
                    keepTrying = false; // get out of the while loop
                } else if (searchForMe.compareTo(currentNode.value) > 0) { // Go right
                    if (currentNode.right == null) { // end of tree; no luck
                        keepTrying = false; // exit while loop
                    } else { // keep pushing right
                        currentNode = currentNode.right; // new value for next iteration
                    }
                } else { // Go left
                    if (currentNode.left == null) { // end of tree; no luck
                        keepTrying = false; // exit while loop
                    } else { // keep pushing left
                        currentNode = currentNode.left; // new value for next iteration
                    }
                }
            }
        }
        return success;
    } // method valueExists

    /**
     * Iterative in-Order traversal of the tree
     */
    public void inOrder() {
        if (root == null) { // empty tree
            System.out.println("Tree is empty");
        } else {
            System.out.println("\n\nIn-Order traversal of your tree:\n");
            int wordCount = 1; // tracks how many words are printed before new line
            int wordPerLine = 5; // I want this may words per line
            List nodesToProcess = new ArrayList(); // Simple "stack"
            // Start from the top
            TreeNode currentNode = root;
            // The following loop traverses while there are items in the "stack"
            while ( currentNode != null || nodesToProcess.size() > 0 ) {
                while (currentNode != null) {
                    nodesToProcess.add(0,currentNode);
                    currentNode = currentNode.left; // Go as left as you can
                }
                currentNode = nodesToProcess.get(0); // When no more left, print what's on top of the stack
                System.out.printf("%-15s ",currentNode.value);
                if ( wordCount%wordPerLine==0 ) {
                    System.out.printf("\n");
                }
                wordCount++;
                nodesToProcess.remove(0); // remove the current node from the stack
                currentNode = currentNode.right; // go right
            }
        }
    } // method inOrder

    /**
     * Method to find the smallest node of a tree (or subtree). The smallest node is the
     * left-most node of the tree (or subtree).
     * @param node the root of the tree or subtree we wish to scan
     * @return the node with the smallest value
     */
    public TreeNode minNode(TreeNode node) {
        TreeNode current = node;
        while ( current.left != null) { // Keep going left until no more
            current = current.left;
        }
        return current; // this is the smallest node
    } // method minNode

    /**
     * Method successor finds, iteratively, the node with the next highest value from the
     * node provided. If the node whose successor we seek has a right subtree, the successor
     * is the smallest node of that subtree. Otherwise, we start from the root, towards
     * the node whose successor we seek. Every time we go left at a node, we mark that
     * node as the successor.
     * @param ofThisNode Node whose successor we are seeking.
     * @return The node's successor; null if it has no successor
     */
    public TreeNode successor(TreeNode ofThisNode) {
        TreeNode succ = null;
        if ( ofThisNode.right != null) { // Node whose successor we seek, has a right subtree.
            succ = minNode(ofThisNode.right); // Successor is smallest node of right subtree.
        } else { //
            TreeNode current = root; // Start from root and go towards node whose successor we seek.
            boolean keepTraversing = true; // Switch to exit the while loop when done
            while (keepTraversing) {
                if ( ofThisNode.value.compareTo(current.value ) < 0 ) { // Node whose successor we seek should be to the left.
                    if ( current.left != null ) { // Can we go left?
                        succ = current; // Mark this node as successor
                        current = current.left; // Go left
                    } else { // We can no longer go left -- end of tree?
                        keepTraversing = false; // Signal to exit the while loop.
                    }
                } else { // Node whose successor we seek should be to the right.
                    if ( current.right != null ) { // Can we go right?
                        current = current.right; // Go right
                    } else { // We can no longer go right -- end of tree?
                        keepTraversing = false; // Signal to exit while loop.
                    }
                } // Done deciding left/right as we search for the node whose successor we seek.
            } // Done traversing the tree
        } // Done looking for the successor; we have it (or we end up with null, ie, end of tree).
        return succ;
    } // method successor

    /** Quick testing */
    public static void main (String[]args){

        // Instantiate a binary search tree.
        BST sycamore = new BST();

        // Favorite soliloquy to be used as content for the tree
        String text = "Now is the winter of our discontent " +
                "Made glorious summer by this sun of York; " +
                "And all the clouds that lour'd upon our house " +
                "In the deep bosom of the ocean buried.";

        // Split soliloquy into separate words (converting to lower case for uniformity).
        String[] words = text.toLowerCase().replaceAll("[^a-zA-Z ]", "").split(" ");

        // Add to tree.
        for (String word : words) {
            sycamore.insert(word);
        }

        // Print the tree using the in-Order traversal
        sycamore.inOrder();

    } // method main

} // class BST

In: Computer Science

JAVA PROGRAMMING For this assignment, review the successor method in BST. The successor of a node...

JAVA PROGRAMMING

For this assignment, review the successor method in BST. The successor of a node is the node with the next highest value in the tree. The successor of the node with the largest value in a tree, is null. The algorithm to find the successor of a node is straight forward: if the node has a right subtree, the successor is the smallest node in that subtree (for that we use method minNode). Otherwise, we traverse the tree from the root and towards the node whose successor we are seeking. Each node at which we continue to traverse left, we mark as the successor. The last such node is the actual successor.

TreeNode with parent node

Modify BST so that each TreeNode has a pointer to its parent node. (The only node without a parent is the root node). Ensure that every time you add a node to a tree, that all points (left, right, and parent) are updated as needed.

Successor search using the parent node

Write a new method, with signature

TreeNode successorP(TreeNode ofThisNode) that finds the successor of a node without traversing the tree from the root, but by using the knowledge captured in the parent field. There are many variants of this technique online. Many of them are incomplete or may contain bugs. Make sure that your code works perfectly well with each node in the test tree sycamore. Your code must be welldocumented with meaningful comments.

Delete a node

Write a method with signature

boolean deleteNode(TreeNode deleteMe)
that implements the deletion algorithm as discussed in class. The deletion algorithm is as follows:

If node-to-delete has zero children, just dereference it from its parent.

If node-to-delete has one child only, its child is "adopted" by its parent.

If the node-to-delete has two children, swap it with its successor, reducing the case to one of the previous two.

For this problem, use the parent field in TreeNode.

import java.util.ArrayList;
import java.util.List;

/**
* A simple Binary Search Tree (BST) class.
*/
public class BST {

// A tree is just a root, really! Everything grows from here.
private TreeNode root; // what's a TreeNode? See below.

// And here's what a TreeNode looks like.
class TreeNode {
String value; // The data we store in this node
TreeNode left; // left child
TreeNode right; // right child
// basic constructor
public TreeNode(String s) {
this.value = s; // assigns content to String
left = right = null; // makes pointers to children null
} // constructor TreeNode
} // class TreeNode


/**
* Inserts unique value into tree; if value already
* exists, method returns false.
*
* @param s value to insert
*/
public boolean insert(String s) {
boolean success = false;
if (!valueExists(s)) { // Value is not stored in tree already; we can add it
success = true; // Method will return this value to indicate successful insertion
TreeNode newNode = new TreeNode(s); // Node with new value to be inserted
if (root == null) { // If tree is empty,
root = newNode; // new node becomes its root.
} else { // Start our search from the root to find where to place new node.
TreeNode currentNode = root; // We start our search from the root.
boolean keepTrying = true; // Control variable from the principal loop, below.
while (keepTrying) { // Principal loop; exits only when keepTrying becomes false.
if (s.compareTo(currentNode.value) > 0) { // New value is greater than current node; go RIGHT
if (currentNode.right == null) { // If right child is null
currentNode.right = newNode; // place new value here
keepTrying = false; // Flag to exit the principal loop.
} else { // Right child is not null
currentNode = currentNode.right; // Make right child the current node and try again.
}
} else { // New value is less than current node; go LEFT
if (currentNode.left == null) { // If left child is null
currentNode.left = newNode; // place new value here.
keepTrying = false; // Flag to exit the principal loop.
} else { // Left child is not null.
currentNode = currentNode.left; // Make left child the current node and try again.
}
}
}
}
}
return success;
} // method insert

/**
* Find if String searchForMe exists in the tree, in an iterative scan
*
* @param searchForMe Value to search for
* @return true if searchForMe found; false otherwise
*/
public boolean valueExists(String searchForMe) {
boolean success = false; // Assume String is not in the tree.
if (root != null) { // Start searching from the top.
TreeNode currentNode = root; // initialize iterative node
boolean keepTrying = true; // Loop control flag
while (keepTrying) {
if (currentNode.value.compareTo(searchForMe) == 0) { // found!
success = true; // flag success
keepTrying = false; // get out of the while loop
} else if (searchForMe.compareTo(currentNode.value) > 0) { // Go right
if (currentNode.right == null) { // end of tree; no luck
keepTrying = false; // exit while loop
} else { // keep pushing right
currentNode = currentNode.right; // new value for next iteration
}
} else { // Go left
if (currentNode.left == null) { // end of tree; no luck
keepTrying = false; // exit while loop
} else { // keep pushing left
currentNode = currentNode.left; // new value for next iteration
}
}
}
}
return success;
} // method valueExists

/**
* Iterative in-Order traversal of the tree
*/
public void inOrder() {
if (root == null) { // empty tree
System.out.println("Tree is empty");
} else {
System.out.println("\n\nIn-Order traversal of your tree:\n");
int wordCount = 1; // tracks how many words are printed before new line
int wordPerLine = 5; // I want this may words per line
List nodesToProcess = new ArrayList(); // Simple "stack"
// Start from the top
TreeNode currentNode = root;
// The following loop traverses while there are items in the "stack"
while ( currentNode != null || nodesToProcess.size() > 0 ) {
while (currentNode != null) {
nodesToProcess.add(0,currentNode);
currentNode = currentNode.left; // Go as left as you can
}
currentNode = nodesToProcess.get(0); // When no more left, print what's on top of the stack
System.out.printf("%-15s ",currentNode.value);
if ( wordCount%wordPerLine==0 ) {
System.out.printf("\n");
}
wordCount++;
nodesToProcess.remove(0); // remove the current node from the stack
currentNode = currentNode.right; // go right
}
}
} // method inOrder

/**
* Method to find the smallest node of a tree (or subtree). The smallest node is the
* left-most node of the tree (or subtree).
* @param node the root of the tree or subtree we wish to scan
* @return the node with the smallest value
*/
public TreeNode minNode(TreeNode node) {
TreeNode current = node;
while ( current.left != null) { // Keep going left until no more
current = current.left;
}
return current; // this is the smallest node
} // method minNode

/**
* Method successor finds, iteratively, the node with the next highest value from the
* node provided. If the node whose successor we seek has a right subtree, the successor
* is the smallest node of that subtree. Otherwise, we start from the root, towards
* the node whose successor we seek. Every time we go left at a node, we mark that
* node as the successor.
* @param ofThisNode Node whose successor we are seeking.
* @return The node's successor; null if it has no successor
*/
public TreeNode successor(TreeNode ofThisNode) {
TreeNode succ = null;
if ( ofThisNode.right != null) { // Node whose successor we seek, has a right subtree.
succ = minNode(ofThisNode.right); // Successor is smallest node of right subtree.
} else { //
TreeNode current = root; // Start from root and go towards node whose successor we seek.
boolean keepTraversing = true; // Switch to exit the while loop when done
while (keepTraversing) {
if ( ofThisNode.value.compareTo(current.value ) < 0 ) { // Node whose successor we seek should be to the left.
if ( current.left != null ) { // Can we go left?
succ = current; // Mark this node as successor
current = current.left; // Go left
} else { // We can no longer go left -- end of tree?
keepTraversing = false; // Signal to exit the while loop.
}
} else { // Node whose successor we seek should be to the right.
if ( current.right != null ) { // Can we go right?
current = current.right; // Go right
} else { // We can no longer go right -- end of tree?
keepTraversing = false; // Signal to exit while loop.
}
} // Done deciding left/right as we search for the node whose successor we seek.
} // Done traversing the tree
} // Done looking for the successor; we have it (or we end up with null, ie, end of tree).
return succ;
} // method successor

/** Quick testing */
public static void main (String[]args){

// Instantiate a binary search tree.
BST sycamore = new BST();

// Favorite soliloquy to be used as content for the tree
String text = "Now is the winter of our discontent " +
"Made glorious summer by this sun of York; " +
"And all the clouds that lour'd upon our house " +
"In the deep bosom of the ocean buried.";

// Split soliloquy into separate words (converting to lower case for uniformity).
String[] words = text.toLowerCase().replaceAll("[^a-zA-Z ]", "").split(" ");

// Add to tree.
for (String word : words) {
sycamore.insert(word);
}

// Print the tree using the in-Order traversal
sycamore.inOrder();

} // method main

} // class BST

In: Computer Science