Questions
Write a class called Name. A tester program is provided in Codecheck, but there is no...

Write a class called Name. A tester program is provided in Codecheck, but there is no starting code for the Name class. The constructor takes a String parameter representing a person's full name. A name can have multiple words, separated by single spaces. The only non-letter characters in a name will be spaces or -, but not ending with either of them.

The class has the following method:

• public String getName() Gets the name string.

• public int consonants() Gets the number of consonants in the name. A consonant is any character that is not a vowel, the space or -. For this problem assume the vowels are aeiou. Ignore case. "a" and "A" are both vowels. "b" and "B" are both consonants.

You can have only one if statement in the method and the if condition cannot have either && or ||. Do not use the switch statement, which is basically the same as an if statement with multiple alternatives. Hint: call method contains().

- public String initials() Gets the initials of the name.

Do not use nested loops for the method. Hint for initials(): Each word after the first is preceded by a space. You can use the String method indexOf (" ", fromIndex) to control a while loop and to determine where a new word starts. This version of indexOf() returns the index of the first space starting at the fromIndex. The call of indexOf (" ", fromIndex) returns -1 if the space is not found in the string. Remember that the name does not have 2 consecutive spaces and does not end in a space.

NameTester.java

/**
 * A Java tester program for class Name.
 *
 * @author  Kathleen O'Brien, Qi Yang
 * @version 2020-07-25
 */
public class NameTester
{
    public static void main(String[] args)
    {
        Name name = new Name("Allison Chung");
        System.out.println(name.getName()); 
        System.out.println("Expected: Allison Chung");
        System.out.println(name.consonants());
        System.out.println("Expected: 0");
        
        name = new Name("a-abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        System.out.println(name.getName()); 
        System.out.println("Expected: a-abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        System.out.println(name.consonants());
        System.out.println("Expected: 0");
        
        name = new Name("Alhambra Cohen");
        System.out.println(name.initials());
        System.out.println("Expected: null");
        
        name = new Name("George H W Bush");
        System.out.println(name.initials());
        System.out.println("Expected: null");
        
        name = new Name("John Jacob Jingleheimer Schmidt");
        System.out.println(name.initials());
        System.out.println("Expected: null");
        
        name = new Name("Zorro");
        System.out.println(name.initials());
        System.out.println("Expected: null");
    }
}

In: Computer Science

Python 10 - (10 pts) - Implement a program that starts by asking the user to...

Python

10 - (10 pts) - Implement a program that starts by asking the user to enter a userID (i.e., a string). The program then checks whether the id entered by the user is in the list of valid users.

The current user list is: ['joe', 'sue', jamal, 'sophie']

Depending on the outcome, an appropriate message should be printed. Regardless of the outcome, your function should print 'Done.' before terminating.

Here is an example of a successful login:

>>> Login: joe

Welcome back, joe

Done.

And here is one that is not:

>>> Login: john

Unknown users or passwords

Done.

11 – (10 pts) - Using Python, create a random password generator with length = 10 characters. The password should consist of upper- and lower-case letters and digits.

12 - (15 pts) - An acronym is a word formed by taking the first letters of the words in a phrase and then making a word from them. For example, RAM is an acronym for random access memory.

Write a function acronym() that takes a phrase (i.e., a string) as input and then returns the acronym for that phrase.

Note: The acronym should be all uppercase, even if the words in the phrase are not capitalized.

>>> acronym('Random access memory')

'RAM'

>>> acronym('central processing unit')

'CPU'

13 - (10 pts) – Using Python, write a segment of code to populate the table "employee" of the database "EmployeeDB” with the data below. Import your choice of DB connector (import MySQLdb/sqlite3…)

Create the“employee” table with schema = [name, address, age]

Insert this employee: John Doe, 7001 E Williams Field, 32

14 - (20 pts) - Define a class called Animal that abstracts animals and supports three methods:

setSpecies(species): Sets the species of the animal object to species.

setLanguage(language): Sets the language of the animal object to language.

speak(): Prints a message from the animal as shown below.

The class must support supports a two, one, or no input argument constructor.

Then define Duck as a subclass of Animal and change the behavior of method speak() in class Duck.

>>> snoopy = Animal('dog', 'bark')

>>> snoopy.speak()

I am a dog and I bark.

>>> tweety = Animal('canary', ‘tweet’)

>>> tweety.speak()

I am a canary and I tweet

>>> animal = Animal()

>>> animal.speak()

I am an animal and I make sounds.

>>> daffy = Duck()

>>> daffy.speak()

quack! quack! quack!

In: Computer Science

In the mid-1990s, Colgate-Palmolive developed a new toothpaste for the U.S. market, Colgate Total, with an...

In the mid-1990s, Colgate-Palmolive developed a new toothpaste for the U.S. market, Colgate Total, with an antibacterial ingredient that was already being successfully sold overseas. At that time, the word antibacterial was not allowed for such products by the Food and Drug Administration (FDA). In response, the name “Total” was given to the product in the United States. The one word would convey that the toothpaste is the “total” package of various benefits. Young & Rubicam developed several commercials illustrating Total’s benefits and tested the commercials with focus groups. One commercial touting Total’s long-lasting benefits was particularly successful. The product was launched in the United States in January of 1998 using commercials that were designed from the more successful ideas of the focus group tests. Suppose 32% of all people in the United States saw the Total commercials. Of those who saw the commercials, 40% purchased Total at least once in the first 10 months of its introduction. According to U.S. Census Bureau data, approximately 20% of all Americans were in the 45-64 age category. Suppose 24% of the consumers who purchased Total for the first time during the initial 10-month period were in the 45-64 age category. Within three months of the Total launch, Colgate-Palmolive grabbed the number one market share for toothpaste. Ten months later, 21% of all U.S. households had purchased Total for the first time. The commercials and the new product were considered a success. During the first 10 months of its introduction, 43% of those who initially tried Total purchased it again.   

  1. What percentage of U.S. households purchased Total at least twice in the first 10 months of its release?
  1. Can you conclude the initial purchase of Total was independent of age? Use a quantitative argument to justify your answer.
  1. Calculate the probability that a randomly selected U.S. consumer is either in the 45-64 age category or purchased Total during the initial 10-month period.
  1. What is the probability that a randomly selected person purchased Total in the first 10 months given that the person is in the 45-64 age category?

e. What percentage of people who did not see the commercials purchased Total at least once in the first 10 months of its introduction?

In: Statistics and Probability

Review information for The South African Motor Industry (The South African motor industry originally emerged through...

Review information for The South African Motor Industry (The South African motor industry originally emerged through the assembly of knock-down kits of parts from abroad. Over the years, these developed into fully fledged manufacturers. This was largely due to the active industrial policies of the apartheid government (in power from 1948 to 1994), which aggressively promoted import substitution. Under apartheid, racial discrimination in the communities was mirrored by racial Fordism: blacks were largely condemned to poorly paid unskilled work. This led to many industries relying on cheap labor to solve systemically imposed inefficiencies.

In the 1970s, a wave of unionization of blacks took place, eclipsing the older, white- dominated trade unions. By the early 1980s, the new (“independent”) unions became increasingly outspoken in opposing the apartheid order. Mass resistance in communities was paralleled by an upsurge in strike action. In the Mercedes-Benz plant in East London, the resistance became so intense that large areas of the factory were rendered no-go areas for management. Finally a grouping of workers occupied the plant, damaging inventories and machinery.

The close of the apartheid era alleviated much of the underlying tension; at the same time, managers began to forge cooperative deals with unions. At Mercedes-Benz, these included very much better pay and working conditions, new opportunities for up-skilling and career advancement and a range of participative mechanisms, giving workers a real say in the process of production. Today, the plant is one of the most productive car plants in the world, and its products have the fewest defects of any Mercedes-Benz plant. While previously the plant was marginal, and by the late 1980s under threat of closure, today it is an integral part of the Mercedes-Benz worldwide production network.) case 3.1 then answer the following questions in accordance with the criteria below (Write 150 word minimum for each question, points will be deducted if each question does not meet the minimum 150-word required for each question):

1.       Summarize the study

2.       What lessons does the Mercedes-Benz East London plant hold for HR managers worldwide?

3.       Is the experience of Mercedes-Benz in East London relevant to other industries.

4.       If yes, please explain. If not, why not, please explain.

In: Operations Management

1. Significant time and effort was/were spent on perfecting her cover letter. Everyone in the accounting...

1.

Significant time and effort was/were spent on perfecting her cover letter.

Everyone in the accounting department was/were instructed on how to politely answer incoming calls.

The members of the Professional Committee is/are   disagreeing on how to allocate funds.

One of the male candidates failed to submit his/their cover letter.


2. Choose the sentence that is punctuated correctly.

A. Traditional job-search techniques, such as those described in your job handout, continue to be critical in landing jobs.

B. Traditional job-search techniques, such as those described in your job handout continue to be critical in landing jobs.

C. Traditional job-search techniques such as those described in your job handout continue to be critical in landing jobs.

3.

Choose the sentence that is punctuated correctly.

A. When customizing your résumé, make sure to include keywords that describe your skills, traits tasks and job titles associated with your targeted job.

B. When customizing your résumé, make sure to include keywords that describe your skills traits tasks and job titles associated with your targeted job.

C. When customizing your résumé, make sure to include keywords that describe your skills, traits, tasks, and job titles associated with your targeted job.

Choose the sentence that is punctuated correctly.

A. When you are organizing your qualifications, try to create as few headings as possible; more than six make the document look cluttered.

B. When you are organizing your qualifications, try to create as few headings as possible more than six make the document look cluttered.

C. When you are organizing your qualifications, try to create as few headings as possible, more than six make the document look cluttered.


4.

In the following sentences, select the correct word to fill in the blank.

When applying for a job, make sure all of your correspondence/corespondence   is concise and professional.

Make sure to highlight any professional development/development you have obtained over your career.

Choose the sentence that uses the correct word.

A. I would like to express my interest in this position formally.

B. I would like to express my interest in this position formerly.

In: Psychology

(T or F)   C++ throws an exception if you try to refer to element 47 in...

  1. (T or F)   C++ throws an exception if you try to refer to element 47 in an array with 20 elements.
  2. (T or F)   I can copy one array to another by simply using an assignment statement which assigns the one array to the other.
  3. (T or F) An exception is the occurrence of an erroneous or unexpected situation during the execution of a program.
  4. (T or F) The try / catch structure is used to test for and catch occurrences of syntax errors.
  5. (T or F) There can be no code between a try-block and its associated catch-block.
  6. (T or F) The reserved word throw is used to signal that an exception has occurred.
  7. (T or F) The correct use of throw can be anywhere in a program; a try / catch structure is used only in class definitions.
  8. (T or F) In C++, class is not a reserved word.
  9. (T or F) Class attributes have no fixed type; their type can be changed during the program execution.
  10. (T or F) A member of a class can be a method or an attribute.
  11. (T or F)The private attributes of a class cannot be accessed by the public methods of that class.
  12. (T or F) The initialization of a variable in the declaration

Ex: int counter = 0;

is not allowed inside a class definition.

  1. (T or F) In C++ a class is a definition; it does not exist in RAM until an object is created, using the definition.
  2. (T or F) A member of a class that was created “on the stack” (locally) can be accessed by using the dot operator (.) followed by the member name.
  3. (T or F) Class objects can be passed to methods as arguments and can be returned from methods.
  4. (T or F) A class constructor is a method that automatically is called whenever an object is created from the class.
  5. (T or F) a class destructor is another name for a no-arg constructor..
  6. (T or F) a class cannot have more than one constructo
  7. (T or F) a class can have a destructor to match each constructor.
  8. (T or F) The primary purpose of the separation of a class interface from the class implementation enables the code to be more easily read by a human programmer.
  9. (T or F) Every time any method is called, a new “frame” is created in RAM.
    1. (T or F) A “pure” class definition can contain only methods.
    1. (T or F) A class definition by itself, takes very little space in RAM.

In: Computer Science

Instructions This posting should be a minimum of one short paragraph and a maximum of two...

Instructions

This posting should be a minimum of one short paragraph and a maximum of two paragraphs. Word totals for this post should be in the 100–200-word range. Whether you agree or disagree, explain why with supporting evidence and concepts from the readings or a related experience. Include a reference, link, or citation when appropriate.

Preparation

To attract the best talent, many employers have expanded their employee incentives and benefits offerings. You read about some of the perks Google offers, such as free food and haircuts, on-site gyms and medical facilities, and more. Some other benefits that have been the topics of recent news stories include paid parental leave and unlimited vacation policies.

While the Family Medical Leave Act guarantees 12 weeks of unpaid leave to new parents, there are no US laws guaranteeing any paid leave. But many companies in the tech sector and beyond have expanded their paid parental leave policies in recent years, including Netflix, Microsoft, Ikea, and Nike. Other companies, such as Apple and Facebook, even offer egg freezing and IVF benefits to employees.

Another benefit some companies are trying out is an unlimited vacation time policy. While the idea that you can take off as much time as you like is appealing to many job-seekers, some evidence suggests that employees at these companies actually take less time off than those at companies with more traditional vacation policies.[1] Advocates of unlimited time-off policies cite trust between employees and managers as a key factor in making them work.

For Discussion

Choose ONE of the following questions to respond to in your initial post.

  1. What benefits and incentives do you think are most appealing to employees, and why?
  2. What challenges do benefits like extended parental leave and unlimited paid time off present to managers? How might managers address these challenges?
  3. Research some other unique employee benefits or incentives. Share what you discover, and include a link to the article or site. Do you think these incentives would be attractive to employees? Why or why not?
  4. If you were working as an HR manager, what benefits and incentives would you recommend that the company offer? Why?

In: Operations Management

Programming language to be used: Java Exercises Part 1) The Dog Class In the first part...

Programming language to be used: Java

Exercises

Part 1) The Dog Class

In the first part of the lab, we are writing a class to represent a Dog. It should not have a main method.

  1. Dog needs fields for price (to purchase the dog), breed, name, and age. Use appropriate data types
  2. The class should have the following two kinds of Constructors:
    1. Constructor 1: Write a constructor that accepts a value for each of the fields
    2. Constructor 2: Write a constructor that accepts no arguments and sets default values of your choice
  3. The Dog class requires:
    1. Setters and getters for all fields
    2. A toString() method, which
      1. Returns String
      2. Returns a String describing the dog, such as

Sebastian the Husky is 5 years old.
$45.56 adoption fee

  1. Please note that the dollars must be formatted that way

Part 2) The Sales Class

In the second part of the lab, we are writing a class to represent the buying of a Dog or multiple Dogs. Let’s not consider the logistics of buying Dogs in bulk.

  1. The Sales class has the following fields – a PrintWriter for a file being used (as well as any other fields you decide you want to help with that) and a double holding the total price of dogs purchased
  2. A Sales class has one constructor – it should take a file name to save the output to
  3. The Sales class needs the following functions
    1. An addDog method, which saves a new dog to the file (using the toString to get the String representation) and adds the price to the total double
    2. A finalizeReport method, which closes the file after adding a bottom line (“----“) and printing the total price below that line, properly formatted

Part 3) The DogMarket Class

This class should get a file name from the user. It should use the file to create a Sales class object. Then, it should prompt the user for details of the dogs they want to buy. Use a while loop, which uses the word “quit” to not buy a dog and the word “buy” to buy a dog – other words should be ignored, but should not quit the program. If the user says “buy”, ask them for all of the dog’s info, then make a new Dog object and save it to the file using the Sales object. Once the user is done buying dogs, the program should exit, being sure to use finalizeReport() on the sales object

In: Computer Science

in Python3 The ord function in Python takes a character and return an integer that represents...

in Python3

The ord function in Python takes a character and return an integer that represents that character.
It does not matter what the integer representing the character actually is, but what matters is this:

ord('a') is 1 less than ord('b'), so that:

x=ord('a')
thisLetter = x+1 # thisLetter is the ord('b')

This is a powerful fact that is used in encryption techniques, so data transferred over the web is 'ciphered so it is unreadable to others.

To decipher data, we take a string and change it into another string by adding a constant (called the key) to each of its letters' ord value.
See the book's Case study: word play.

To cipher and decipher data, we need two functions: one to take a string, and change it to something else. For this we need to use the ord function, and add the 'key' to result in a new string. For example, say x is one letter to be ciphered, and the key is 3. We can use:

Newx=ord(x)+3

Newx will be an integer. To find out what letter that integer represents you can use the chr function as in:
actualLetter = chr(x)

Write a function named cipher that takes a string.
The function returns that string in a ciphered form by using the ord of the first letter of the string to cipher each letter including the first letter. Hence for abc, use the ord of 'a', and add it to the ord of 'a' and convert that result to a character use the chr function. This character should be concatenated to the same action on the letter b and so on. Hence the function returns:

chr(ord('a')+ord('a')) + chr(ord('a')+ord('b')) + chr(ord('a')+ord('c')).
Obviously you need a loop to iterate on each letter.

Write another function to decipher (do the opposite of the previous function), given a string and returns the deciphered string. Obviously, the first letter's ord is halved to find the first letter, and that value is used to decipher the remaining letters.

From main, write code to get a string, as input, then call the cipher function and print its output.
Then call the decipher function and display its output. The decipher output should match the original string.

For help on this see the book's Case study: word play.

Add comments as needed but make sure to add top level comments.

In: Computer Science

For each short answer, the word limit is 100 words. You need to make assumption clear, reasonable and explicit if making any. The quality and logic of arguments determine your marks.

 

For each short answer, the word limit is 100 words. You need to make assumption clear, reasonable and explicit if making any. The quality and logic of arguments determine your marks. (4 marks each)

  1. Donald Trump promised a more aggressive fiscal policy with a large increase in spending and significant tax cuts leading to a much larger government (budget) deficit. The US economy was at near the full employment (the unemployment rate in the US was low below 5%), what do you expect will be the response of the US Central Bank in terms of changes to the cash rate? Explain.

Answer

 

 

  1. The Central Bank of New Zealand has a higher inflation target than the Reserve Bank of Australia. Does this tend to depreciate or appreciate the New Zealand dollar against the Australian dollar? Explain

Answer

 

  1. What are the reasons for increasing convergence between emerging economies (defined as countries with lower GDP per capita but growing rapidly) and advanced economies (countries with high GDP per capita but lower growth)? Explain.

Answer

 

 

 

 

 

 

 

  1. You have successfully secured the mortgage of worth in $1,000,000 from the Bank to purchase a house. After the contract has been written, inflation in the economy turned out to lower than what was expected. Who gained and lost from this development? Explain.

 

Answer

 

  1. The government (and the central bank) has an easier job of dealing with the macroeconomic impacts of consumers and investors being pessimistic about the future of the economy than the period of stagflation. Do you agree? Explain

 

Answer

 

In: Economics