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 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 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.
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 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 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.
In: Psychology
Ex: int counter = 0;
is not allowed inside a class definition.
In: Computer Science
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.
In: Operations Management
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.
Sebastian the Husky is 5 years
old.
$45.56 adoption fee
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.
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 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. (4 marks each)
Answer
Answer
Answer
Answer
Answer
In: Economics