sortJAVA

Downloads 1

Given the following code
interface WritingTool
{
public double getWordsLeft(int newWords);
}
you are required to create two classes.First, write the code for an abstract class named Pen that implements the WritingTool interface.
Pen should have an integer attribute called wordLimit which represents the number of words that can be written during the life of a Pen. The default value for wordLimit is one million.Next, create a concrete class that is derived from Pen called BallPointPen.
BallPointPen has an integer attribute called futureWords that represents the number of words that can be written by the pen in the future. For a BallPointPen, calling getWordsLeft will result in the futureWords being incremented by newWords, and the returned value will be the difference between the wordLimit and the updated value of futureWords.All attributes should be private in all classes.
Accessors and mutators for all attributes should be provided.
The constructor of each class should initialize it’s attributes.

Search JAVA

Downloads 2

Consider an approach to searching for a key in a sorted array in which we randomly choose an index between the two ends of the array, compare the item at that index with the search key and then either • If the item there equals the key, return the index • If the item there is larger than the key, recursively search to the left of index using the same strategy • If the item there is smaller than the key, recursively search to the right of the index using the same strategy
Write a function search(intO a, int key) to implement this searching algorithm.
Write recurrences that describe the average and worst case behaviors of this algorithm and, without formally solving them, explain what you think the answers will be and why.

Mac Tech

Downloads 3

Mac Tech is a manufacturer of electronic components and accessories with total assets of
$20 000 000. Selected financial ratios for Mach Tech and the industry averages for the firms of similar size are presented below:
Current ratio
Quick ratio
Inventory turnover
Net sales to net worth
Net income to net worth Total liabilities to net worth
Mac Tech
2016 2017 2018
2.09 2.27 2.51 1.15 1.12 1.19 2.40 2.18 2.02 2.71 2.80 2.99 0.14 0.15 .017 1.41 1.37 1.44
2018 Industry Average
2.24 1.22 3.50 2.85 0.11 0.95
Mac Tech is being reviewed by several entities whose interests vary, and the company’s financial ratios are a part of the data being considered. Each of the parties listed below must recommend an action based on its evaluation of Mac Tech’s financial position.
Stanbic Bank. The bank is processing Mac Tech’s application for a new 5-year term note. Stanbic has been Mac Tech’s banker for several years, but must reevaluate the company’s financial position for each major transaction.
Rajell Company. Rajell is a new supplier to Mac Tech, and must decide on the appropriate credit terms to extend to the company.
Taffins Financials. A brokerage firm specializing in the stock of electronics firms that are sold over-the counter, Taffins Financials must decide if it will include Mac Tech in a new fund being established for sale to Taffins Financials.
Working Capital Management Committee. This is a committee of Mac Tech management personnel chaired by the chief operating officer. This committee is charged with the responsibility of periodically reviewing the company’s working capital position, comparing actual data against budgets, and recommending changes in the strategy as needed.
Required:
1. Describe the analytical use of each of the six ratios presented above.
2. For each of the four entities described above, identify two financial ratios, from those presented that would be most valuable as a basis for its decision regarding Mac Tech

Rosewise

Downloads 4

Rosewise is a wholesale distributer of professional equipment and supplies. The company sales have averaged about. $900 000 annually for the 3-year period 2016-2018. The firm’s total assets at the end of 2018 amounted to $850 000. The president of Rosewise Company has asked the controller to prepare a report that summarizes the financial aspects of the company’s operations for the past 3 years. This report will be presented to the Board of Directors at their next meeting.
In addition to comparative financial statements, the controller has decided to present a number of relevant financial ratios which can assist in the identification and interpretation of trends. At the request of the controller, the accounting staff has calculated the following ratios for the 3-year period 2016-2018.
Current ratio
Acid-test (quick) ratio
Accounts receivable turn over
Inventory turnover
Percent of total debt to total asset
Percent of long-term debt to total assets Sales to fixed assets (fixed assets turnover) Sales as a percentage of 2000 sales
Gross margin percentage
Net income to sales
Return to total assets
Return on stockholders equity
2016 2017 2018
1.80 1.89 1.96 1.04 0.99 0.87 8.75 7.71 6.42 4.91 4.32 3.42 51% 46% 41% 31% 27% 24% 1.58 1.69 1.79 1.00 1.03 1.07 36.0 35.1 34.6 6.9% 7.0% 7.2% 7.7% 7.7% 7.8% 13.6% 13.1% 12.7%
In preparation of the report, the controller has decided first to examine the financial ratios independently of any other data to determine if the ratios themselves reveal any significant trends over the 3-year period.
Instruction:
1. The current ratio is increasing while the acid-test (quick0 ratio is decreasing. Required: Using the ratios provided, identify and explain the contributing factor(s) for the apparently divergent trend.
2. In terms of the ratios provided, what conclusion(s) can be drawn regarding the company’s use of financial leverage during the 2016-2018 period.
3. Using the ratios provided, what conclusion(s) can be drawn regarding the company’s net investments in plant and equipment.

RockPaperScissors JAVA

Downloads 5

Create a java programme called rockPaperScissors.java
● Write a program that allows the user to play rock, paper, scissors.
● The program should randomly generate a number (0, 1 or 2), which
represents scissors, rock and paper, respectively. (Hint: look up
Math.random)
● The program should then prompt the user to enter a number (0, 1 or 2).
● Once the user has entered their number, the program should inform
them whether they win, lose or draw.
● The rules of the game are as follows:
○ Scissors beats paper
○ Rock beats scissors
○ Paper beats rock

Interpersonal Relationships

Downloads 6

Interpersonal Relationships
1.
Which of the following is not a reason why we form relationships:
A) Similarity
B) Competency
C) Inadequacy
D) Rewards
E) Proximity
2.
Relational dialectics are:
A) A term Professor Rumrill Teece made up
B) When your friends or family don’t approve of a relationship
C) Opposing tensions that are normal parts of all relationships
D) Conflict that involves not accepting your factationial responsibilities
3.
Which type of person was considered the most appealing?
A) Superior person who blundered
B) Superior person who did not blunder
C) Average person who blundered
D) Average person who did not blunder
4.
The fact that we are likely to choose a mate who we live near or frequently cross paths with points to which reason for forming relationships?
A) Similarity
B) Competency
C) Adequacy
D) Reciprocity
E) Proximity
5.
Initiating, bonding, stagnating and experimenting are all part of
A) communication styles
B) stages of relationship development
C) psychic reflection theory
D) none of the above
6.
Jose and Charlie enjoy their weekly game of basketball. Which form of intimacy are they engaging in?
A) emotional
B) physical
C) intellectual
D) shared activities
7.
In which type of compliance-gaining strategy are hints used most frequently?
A) Relational appeals
B) Indirect appeals
C) Individual appeals
D) Reward and punishment
E) Recognition appeals
8.
In determining the appropriateness of self-disclosure, a person should consider which of the following guidelines?
A) Is the other person going to self-disclose also?
B) Is the other person trustworthy?
C) Is the information helpful to the relationship?
D) Is there adequate time to develop and respond to the self-disclosure?
E) All of the above are guidelines for appropriate self-disclosure.
9.
Complimentarity is when people in a relationship are similar.
A) True
B) False
10.
Two of the most powerful factors influencing desired levels of intimacy are gender and culture.
A) True
B) False
Communication Climate
11.
Which of the following are confirming messages?
A) Endorsement, usefulness and recognition
B) Usefulness, recognition and acknowledgment
C) Recognition, acknowledgment and endorsement
D) None of the above
12.
All of the following are part of defensive communication climates except:
A) Evaluation
B) Control
C) Strategy
D) Neutrality
E) Spontaneity
13.
Messages that communicate, “I know what’s best for you, and if you do as I say, we’ll get along” are associated with which component of communication climates?
A) Control
B) Spontaneity
C) Neutrality
D) Strategy
E) Problem-orientation
14.
“I really know a lot more about this than you do, so you should listen to me.” This comment is an example of communication that:
A) Describes the situation
B) Claims superiority of the speaker
C) Expresses a tentative conclusion
D) Demonstrates empathy
E) Focuses on problem solving
15.
Which of the following help to transform negative climates?
A) Guess about specifics
B) Paraphrase the speaker’s ideas
C) Ask what the critic wants
D) Agree with the critic
E) All of the above
16.
Customer: “The amount of time I’ve been on hold is ridiculous. I’m going to cancel my service.” Customer Service Representative: “It sounds like you’re angry. Can you tell me about your problem?” The listener’s response is an example of:
A) Paraphrasing the speaker’s idea
B) Agreeing in principle
C) Agreeing with the truth
D) Agreeing with the odds
E) None of the above
17.
All of the following are types of supportive communication identified by Jack Gibb except
A) description
B) problem-orientation
C) empathy
D) certainty
E) equality
Managing Conflict
18.
Which of the following is (are) a potential benefit of conflict for interpersonal relationships?
A) Partners increase understanding of each other
B) Personal growth of each partner
C) Enlarging our perspective on issues and feelings
D) Just A and C
E) A, B, and C
19.
Lenny says, “I don’t like to lose arguments. The way I figure it, when you have a disagreement there can only be one winner.” Lenny’s orientation to conflict is best described as
A) Lose – lose
B) Win – win
C) Win – lose
D) Exit
E) Ambushing
20.
Unlike Lenny, Janet believes that nobody can win when conflict erupts. From her perspective, everyone is hurt by conflicts. Janet’s orientation to conflict is best described as
A) Lose – lose
B) Win – win
C) Win – lose
D) Exit
E) Loyalty
21.
Which of the following is not one of the Individual Conflict Styles?
A) Avoidance
B) Accommodation
C) Conniption
D) Competition
E) Compromise
22.
Making fun of another person’s preferences is common to which style of handling conflict?
A) Avoidance
B) Accommodation
C) Compromise
D) Competition
E) Collaboration
23.
The following are part of the seven-step approach to a “win-win” solution:
A) Define your needs
B) Listen to the other person’s needs
C) Generate possible solutions
D) Follow up on the solution
E) All of the above are part of the seven-step approach

FreqCont

Downloads 7

Write a main() routine that first prompts the user for their full name. Read this all into a c-string (we can assume that their name will be 79 characters long or less), and welcome them as seen in the sample runs.Then, prompt them to enter lowercase letters at their will that will be analyzed by your program. The user can enter multiple letters per line (words, random letters, whatever), or a single letter per line as the program runs. The program should read this data in one char at a time, and analyze one char at a time. ‘Analyze’ them by keeping track of the frequencies of the letters entered by the user by adding one to each letter’s frequency count. Obviously, begin the frequencies of all letters at 0. The user can stop the letter analysis by entering a ?. User entries that do not begin with a letter a-z should not count towards any letter’s frequency. When the user enters a ? to stop analyzing letters, call your getResults() function, and based on its return value, print out the most common letter(s) the user entered (see sample runs)REQUIREMENT for main():
Use two arrays in your program, declared at the beginning of main() — one that stores the literal char values of each character of the alphabet, a-z , and the other that keeps track of letter frequencies (type int). These arrays should be used one-to-one (in parallel), meaning that the first element (index 0) in the frequency array should correspond to frequency for ‘a’, the second element (index 1) in the frequency array should correspond to frequency for ‘b’, etc. The idea is to read in a letter, search your letter array for that letter, and increase the appropriate frequency for that letter in your frequency array.When the user is done entering letters, call a function you write called getResults() that takes in the two arrays as parameters, and returns the frequency value of the most common letter(s) as an int (note that more than one letter may have the highest frequency count). Based on how this function uses your arrays, think about if the arrays should be passed to the functions as const or not. This function should print out a table of the frequencies of each letter. If a letter was never entered by the user (aka, the frequency of a letter is 0), do not print out an entry for that letter. Output should match mine below exactly.HINTS:
– When reading in the user’s name at the beginning, remember, their name may contain spaces… you may need to use getline to help here.
– Read in and analyze one letter at a time (read each char into a character variable using >> , and increase frequency for that letter).
– Read up on passing arrays into functions — we’ll cover this in class, too.
– Utilize loops where necessary.
– The user is free to enter special characters, uppercase letters, or numbers. Just do not count these towards any letter frequencies. – Remember that the extraction operator >> skips over whitespace too, so this helps by ignoring spaces, newlines, tabs, etc, as well.
– You may assume the user will enter at least one valid lowercase letter before entering a ? to quit.Sample Run 1:(user input underlined)What’s your name? Melina Myers
Welcome, Melina Myers!
Enter as many words or letters as you’d like, and I’ll count them up!
When you’re done, enter a ? character.fuzzy wuzzy was a bear
fuzzy
wuzzy
h
a
d
no
hair
?Thanks for using the letter counter Melina Myers!Here’s your results:Letter Frequency
———————————-
a 5
b 1
d 1
e 1
f 2
h 2
i 1
n 1
o 1
r 2
s 1
u 4
w 3
y 4
z 8The letter(s) appearing most were:
z
with 8 occurrences

CSC401-Homework4

Downloads 8

Implement the functions below in the file csc401-homework4.py which can be found onthe D2L site
in the Session 4 folder. You should save the template file I provided and then modify that file by adding the bodies for the functions. When you do, make sure to remove the placeholder pass statements that are currently there.
A note about the built-in tests: these should not be your only testing. I will test your code with other inputs besides those shown in the test and your code should still work if I have used valid values.

Problem descriptions
1. Implement a function named convert_2_km(), which has no parameters. It converts user input from miles into kilometers. The formula for this conversion is: 1 mile == 1.60934 kilometers.
Steps
a.
In a loop, prompt the user for a value in miles

b.
If the user enters “STOP”, exit the function but DO NOT use the exit() function

c.
if the user enters a valid number, show the conversion

d.
if the user enters an invalid value, show an error message and prompt again

Example of usage
>>> convert_2_km() Miles (or STOP): 12 Kilometers: 19.31208 Miles (or STOP): cats Bad input: cats Miles (or STOP): 3 Kilometers: 4.82802 Miles (or STOP): stop Bad input: stop Miles (or STOP): STOP
Please notice that this function has no self test.
2. Implement a function meal_price(items) that calculates and returns the price for a meal. Its only parameter is a list containing meal item names. The goal of the function is to compute the price of the meal. The only items the function should recognize are:
apple : 0.59 burger : 2.50 drink : 0.99 fries : 1.29
If the list contains anything else, print “Unknown item: ___” and include the item name that is unknown.An unknown item should not stop the process of adding up the price.
Review the test file for example usage.
3. Implement a function print_change(row) that calculates and prints the difference between adjacent values in a list. The differences are printed separated by commas. For example, if row is [1,2,9], the output should be “1,7” (not including the quote marks) because 2 compared to 1 is 1 greater and 9 compared to 2 is 7 greater. Negative results are expected. If the input was [1,9,2], the expected result is “8,-7”.
The length of the list should not matter. You do not need to test for a list that is too short.
See the test file for more examples.
4. Implement a function sum_nums(a_list) that sums the numbers from the provided list and returns the result. Note that all the values in the list may not be numeric and therefore need to be skipped. For example, sum_nums([5,’11’,27,3,’cat’]) should
return 35. The values ‘11’ and ‘cat’ are skipped.
Use a list comprehension to solve this problem.
See the test file for more examples.

Calculator C++

Downloads 9

Develop a Mathematics Program that can be used to teach learners how to do basic arithmetic, including: add, subtract, multiply, and divide.Prompt the user to input two whole numbers. Either input them one by one or all at
once.Ask the user to enter the symbol that they would like to use, i.e. either add (+),
subtract (-), multiply (*), or divide (/)Make the calculations based on the input provided, then output the answer.Ensure that it handles division by zero, which cannot be done.Ask the user if they would like to perform another mathematical calculation and restart
the processIt should have an exit function to terminate the program.

UsernamePin Python

Downloads 10

• Step 1
• Ask a user to enter the username. The username can contain only letters and numbers.
• If the username contains letters and numbers, the program will move to step 2. Otherwise, the
program will ask the user to enter letters and numbers, and will loop until only letters and
numbers are entered.
• Step 2
• Ask a user to enter the pin code. The pin can contain only 4 digits
• If the pin contains 4 digits, the program will end. Otherwise, the program will ask a user to
enter 4 digits only, and will loop until this condition is satisfied.

×
New Download