Write a program FileCounter.java that reads a text file text1.txt and reports the number of characters and lines contained in the file. For example, the output should be as follows:
Lines: 5 Chars: 124
Note: Write a main() method to test in the FileCounter.java. The file path should use relative path. Must use the provided text file text1.txt.
The text file say
This is an example 1
This is an example 1 2.
This is an example 1 2 3.
This is an example 1 2 3 4.
This is an example 1 2 3 4 5.
2. Suppose you have a binary file geo.dat (see provided data file) of data for a geological survey, such that each record consists of a longitude, a latitude, and an amount of rainfall, all represented by double. Write a program GeologicalData.java to read this file’s data and print them on the screen, one record per line.
Note: Write a main() method to test the code in the GeologicalData.java. The file path should use relative path and the actually file path should be passed into the method getData(String fileName) in the main() method. Must use the provided file geo.dat which has already contained the following data.
-143.78914479979002 59.482245058443084 17.645846630300042 -117.80303714838257 -25.94559103704657 4.513879725440151 49.63942128783603 129.1664680590585 6.825838082783708 -79.66606860669573 -18.800024954102696 9.501515919083086 62.82522223390336 -60.409595996464006 2.6984128008196984
The partial Coding is
public class FileCounter {
}
The other Coding
public class GeologicalData {
public static void getData(String fileName){
}
}
In: Computer Science
PLEASE COMPLETE BOTH PARTS (LANGUAGE: C++ if necessary)
Part I
For the following example, determine the number of comparisons that will take place during a search using both searching algorithms (Linear search and binary search). Also, list each comparison for each algorithm(Linear and binary). The number being searched for is 13.
List = {1,3,5,9,10,11,15,17,19,23,24,25,29,31,33,37,38,39,43,45,47,51,52,53,57,59,61}
Part 2
For the following example, determine the number of swaps that will take place during a sort using both sorting algorithms (bubble and selection sort). Also, list each swap for each algorithm (bubble and selection)
List = {23, 10, 3, -5, 2, 7, 0, 20, 15, 17, 9, 11, 4, 1}
In: Computer Science
Which of the following does not properly describe the Altman Z-score?
Multiple Choice
The Z-score is a multiple discriminant analysis using five financial ratios to estimate default risk.
A high score is an indication of default risk.
The Z-score was originally designed only for publicly traded manufacturing firms.
Each ratio has its own unique weight in calculating the final score.
Cash flow assessment plays a central role in analyzing:
Multiple Choice
the future earnings potential of a company.
the credit risk of a company.
management’s effectiveness.
the firm’s investment potential.
Which of the following statements is false regarding the business valuation process?
Multiple Choice
FASB contends that current accrual earnings are a proxy for free cash flow.
A simplified version of the discounted free cash flow valuation model assumes a zero-growth perpetuity for future cash flows. This approach is best applied to growth companies with stable cash flow patterns.
If a company is currently generating a sustainable free cash flow of $10 per share and the discount rate is 10%, the estimated share price is $100.
One popular approach to estimate a firm’s equity cost of capital is the capital asset pricing model.
Under the abnormal earnings approach of equity valuation, investors willingly pay a premium for those firms that:
Multiple Choice
earn less than the cost of equity capital.
produce negative abnormal earnings.
produce positive abnormal earnings.
earn an amount equal to the equity cost of capital.
In: Finance
Write a function called evenUp that returns the result of increasing the first even digit in a positive integer parameter by 1. (Your solution should use no more than 10 lines of code. Your function can return any convenient value of your choice if the parameter is not positive.) For example, a program that uses the function evenUp follows.
public class P5 {
public static void main(String args[]) {
System.out.println(evenUp(1232)); // prints 1332 only the first even 2 changes
System.out.println(evenUp(1332)); // prints 1333
System.out.println(evenUp(1333)); // prints 1333 no even digit to change
System.out.println(evenUp(22)); // prints 32 System.out.println(evenUp(2)); // prints 3
In: Computer Science
In Unit III, you sent a document in which you informed
management at Gemstone Fabricators, Inc. that it would need to
enhance its accountability specifications in its performance
evaluations for managers. You also pointed out the need to make
sure that employees who have been asked to be involved in the
safety endeavors at Gemstone understand and are trained in the
roles they are expected to play. Cindy is the plant manager from
Gemstone, and she has asked you to perform a sound level survey and
noise dosimetry in the fabrication shop, which can get pretty noisy
when all three mechanical power presses and the 12-foot shear are
running at the same time for several hours a day. She also asked
that you identify noise level exposures in the adjacent welding
department. Your results indicate that the noise levels in the area
are just above the Occupational Safety and Health Administration
(OSHA) permissible exposure level for an average day in the
fabrication department.
The welding department is adjacent to the fabrication department,
and there is no separating wall. The welding operations are not
quite as noisy, although the crackle of a well-adjusted MIG welder
can be rather loud when welding mild steel. Noise monitoring and
dosimetry of the welders indicated an exposure of just over OSHA's
Action Level of 85 Dba. In addition, you remember taking the survey
readings and watching the noise level jump in the welding shop
every time the power presses or shear cycled in the fabrication
area.
After consulting with fellow industrial hygienists, it was
determined that setting up a 12' X 30' noise barrier wall between
the fabrication area and the welding area and adding noise
absorption panels to both sides of the barrier wall and to the
white-painted concrete walls in the fabrication department would
decrease the sound levels in the welding area to several decibels
below OSHA’s Action Level.
Of course, these engineering controls will cost $33,000 dollars.
This is compared to a continuing hearing conservation program to
include annual audiograms, or hearing tests, annual training, and
providing noise protection for the welding department which is
estimated to cost $9,000 per year. This amount would be saved each
year if the engineering controls are installed.
If the company takes out a loan for $33,000 at 5% interest, what
will the payback period be for the loan? Please consult your unit
lesson for the necessary formulas. What would be your
recommendation to the employer with respect to the options
available? Please show your work. Make sure you justify your
reasoning and that you consider the hierarchy of controls in your
discussion.
Your response must be at least 200 words in length in addition to
your financial analysis
In: Operations Management
Through Python, a dictionary or list is often used to store a sequential collection of elements. Suppose, for instance, that you need to read 50 numbers, compute their average, and then compare each number with the average to determine whether it is below or above the average. In order to do this (without the use of list), you would first declare 50 variables to store the 50 numbers. This means you would have to create 50 variables and repeatedly write almost the identical code 50 times. Writing a program this way is impractical. To overcome this issue, you can make use of a list to store all the 50 numbers and access them through a single list variable.
For your initial post, describe the difference between dictionary and list in Python and explain when each would be used. Provide an example of how each dictionary and list would be implemented within Python. 250 WORDS
In: Computer Science
Develop a Java application to implement a binary tree data structure. A tree data structure starts from the top node, called the root. Each node in the tree has a set of children, which are also nodes of the tree and can have children of their own, and so on. This keeps on going till we get to the bottom of the tree, to the “leaf” nodes. Each node in the tree, except for the root, has a parent. A binary tree is a specialized form of a tree data structure in which each node in the tree has at most two children.
A binary tree can be represented using the format in the example below. Each line contains at most three characters. The first character is the ID of the node itself. The next two characters are the child nodes. If a line has only 2 characters, then that node has only one child. If a line has one character only, then it is a leaf node (i.e., it has no children). Example
A B C
B D E
C F G
D H I
E J K
F L
G
H
I
J
K
L
The application should exhibit the following functionality (see the sample output provided):
o If the user wants to add a node, request for the name / ID of the new node to be added as well as the name of the desired parent of that node.
▪ If the parent node already has two children, the new node cannot be added since this is a binary tree (and each node can only have at most two children).
▪If the parent node already has one child, use recursion to add the new node as the second child (right child) of the parent node.
▪ If the parent node has no children, use recursion to add the new node as the left child
of the parent node.
o If the user wants to know the size of the tree (i.e., the number of nodes in the tree or sub-tree), request for the name / ID of the node that is the root of the desired tree / sub-tree. The size of a tree or sub-tree is the number of its children and other ‘descendants’ (including any leaf nodes) plus one – the root node itself. For example, the size of the sub-tree with root ‘B’ in Figure 2 above is 7.
▪ Recursively count the number of nodes in the tree / sub-tree and display this with an appropriate message.
o If the user wants to find a node, request for the name / ID of the node to search for in the tree.
▪ Search recursively for the node in the tree; if the node is found, display an appropriate
message, otherwise, indicate that the node does not exist in the tree.
•Display the menu options.
o If the user wants to exit, terminate the program.
A sample output (to be followed exactly) is included below.
Example Output
ABC
BDE
DHI
H
I
EJK
J
K
CFG
FL
L
G
There are 12 nodes in this tree.
Please select from one of the following options:
1. Add Node
2. Tree Size
3. Find Node
0. Exit
->1
Please input the node you want to add->
P
Please input the parent node of P->
A
Parent already has 2 children.
Please select from one of the following options:
1. Add Node
2. Tree Size
3. Find Node
0. Exit
->1
Please input the node you want to add->
P
Please input the parent node of P->
F
Node successfully added!
ABC
BDE
DHI
H
I
EJK
J
K
CFG
FLP
L
P
G
Please select from one of the following options:
1. Add Node
2. Tree Size
3. Find Node
0. Exit
->2
Please input the root node->
F
There are 3 nodes in that tree
FLP
Please select from one of the following options:
1. Add Node
2. Tree Size
3. Find Node
0. Exit
->3
Please input the node you want to look for->
P
Node P found!
P
Please select from one of the following options:
1. Add Node
2. Tree Size
3. Find Node
0. Exit
->3
Please input the node you want to look for->
N
Node N does not exist.
Please select from one of the following options: 1. Add Node
2. Tree Size
3. Find Node
0. Exit
->0
The main class in your application should be named BinaryTree. This class should instantiate an instance of the second class – to be named TreeDataStructure – and that instance should be used to call the appropriate methods to generate the initial tree, display the menu to the user and exhibit the functionality described above. Apart from the main method, the BinaryTree class should also have a method to print the menu options (void printMenu() ). You can copy and paste the code below into your main class to generate the initial tree.
public static void main(String[] args) {
TreeDataStructure root =
root.addChild("B", "A");
root.addChild("C", "A");
root.addChild("D", "B");
root.addChild("E", "B");
new TreeDataStructure("A");
root.addChild("F", "C");
root.addChild("G", "C");
root.addChild("H", "D");
root.addChild("I", "D");
root.addChild("J", "E");
root.addChild("K", "E");
root.addChild("L", "F");
The TreeDataStructure class should implement the INode interface (which is provided below). The methods addChild(), find(), printTree(), and size() in the TreeDataStructure class must be implemented recursively. NOTE: Using recursion is one of the main objectives of this assignment. A solution that does not use recursion to implement the required functionality will earn zero points. Create an interface named INode within your package (following steps similar to how you would create a class) and copy and paste the interface code below into it.
public interface INode {
public boolean addChild(String ID, String parentID);
public INode find(String value);
public INode getParent();
public int size();
public String toString();
public String getId();
public void printTree();
Hints
In: Computer Science
Dynamic Array
To save computer memory, we need to use dynamic array. In the first
version of our stack implementation, the instance variable has a
fixed capacity, which is 128. There will be an error when the stack
is bigger than 128. For bigger data, you increased the array size.
But that very long array could be wasted for smaller data.
In order to solve this dilemma, we start with a small array, and
increase the capacity only when it is needed. You will modify the
push operation by resizing the array when it overflows. And you
also need to implement the resize(...) method. The details of the
code are in the slides. Submit your dynamic stack in the submission
site here. Your can use the doubling strategy in resizing.
import java.io.*;
import java.util.*;
public class Stack2540ArrayDynamic {
int CAPACITY = 128;
int top;
String[] stack;
public Stack2540ArrayDynamic() {
stack = new String[CAPACITY];
top = -1;
}
public int size() {
return top + 1; }
public boolean isEmpty() {
return (top == -1); }
public String top() {
if (top == -1)
return
null;
return stack[top];
}
// add resize method
// add pop method
public void push(String element) {
// add something here
top++;
stack[top] = element;
}
}
* Please complete the resize, pop, and push methods.
In: Computer Science
Locate a document on the Web that you believe to be an example of an instructional manual. You have two options here: 1) find a good one that you could use as an example for your own, which means that you point to its strengths and try to follow them, or 2) find a bad one that you will use as a cautionary tale for your own, which means you will find the weaknesses so you can avoid them. Find at least 3 discussion points and write a paragraph explaining each.
In: Psychology
PYTHON PROGRAMMING
The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:
For this program, you will employ list data structures to store a group of objects by designing a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.
Once you have completed the program, take a screen shot of the completed functionality (including the input and the output).
Also Describe your process in developing the program in detail.
In: Computer Science
II. Application 1 and 2 run concurrently. Whenever a timeout interrupt occurs, the kernel switches control between the applications. Show the order of instruction execution, assuming application 1 is currently running. (42 pts)
Application 1 |
Application 2 |
... instruction i (timeout interrupt) instruction i+1 ... instruction k (timeout interrupt) instruction k+1 ... |
instruction 0 ... instruction j (timeout interrupt) instruction j+1 ... |
_______
_______
_______
_______
_______
_______
In: Computer Science
Java code: Use Radix sort to sort them in alphabetic order. How many passes would be made through the outer while loop? Trace the contents of the list after each of these passes.
Define the efficiency of the following code fragment:
K := 1
repeat
J := 1
repeat
……..
J := J * 2
until J >= N
K := K + 1
until K >= N
In: Computer Science
java
8.3: Histogram
Design and implement an application that creates a histogram that
allows you to visually inspect the frequency distribution of a set
of values. The program should read in an arbitrary number of
integers that are in the range 1 to 100 inclusive; then produce a
chart similar to the one below that indicates how many input values
fell in the range 1 to 10, 11 to 20, and so on. Print one asterisk
for each value entered.
1 - 10 | *****
11 - 20 | ****
21 - 30 | *********
31 - 40 | **
41 - 50 | **************
51 - 60 | ******
61 - 70 | ****
71 - 80 | ********
81 - 90 | *
91 - 100 | ***
In: Computer Science
G1) If you could rewrite/change the “rules.” how would you improve corporate governance in the United States?
In: Operations Management
A boy pushes his little sister in a sled across the horizontal ground. He pushes down and to the right on the sled at an angle of 35 degrees from the horizontal. The mass of the sled and the sister together is 60 kg. The coefficient of static friction of the sled with the ground is 0.3 and the coefficient of kinetic friction is 0.2. a) Draw a sketch of the situation and a force diagram of the sled, labeling all forces clearly. b) With what force does the boy have to push to start the sled moving from rest? c) If he continues to push with this force after the sled is moving, what will be the sled's acceleration? d) How long will he have to push the sled with this force unitil the it is moving at 2 m/s? e) Discuss whether or not your answers to parts b through d pass the "common sense" test. Be specific about why you think the answers do or do not make sense.
In: Physics