Please add-modify the following to the original code using C# 1- Delet.docxStewartt0kJohnstonh
Pick any employer in Canada and you should pick employers in your familiar area if possible.
1. Summarize the benefits offered by both organizations.
2. Summarise the employee eligibility for both packages.
3. Compare and contrast the benefit packages.
In your opinion, which benefit package is more attractive? Why?
.
Write a method called uniqueNumbers that takes an int array as param.pdffashioncollection2
Write a method called uniqueNumbers that takes an int array as parameter, and returns a
different int array, which only contains the list of unique numbers in the original array. Hint: Use
the isPresent method defined below to accomplish your
here is the code we need to add too
Solution
solution
package com.mt.classes;
import java.util.ArrayList;
import java.util.List;
public class Lab8e {
public static void main(String[] args) {
int[] numbers = new int[20];
// Generate random numbers between 0 and 99 and fill up the array
for (int i = 0; i < numbers.length; i++) {
numbers[i] = (int) (Math.random() * 50);
}
System.out.println(\"The list is:\");
printNumbers(numbers);
// Task 1
System.out.println(\"The smallest number in the list is \"
+ smallestNumber(numbers));
// Task 2
System.out.println(\"The largest number in the list is \"
+ largestNumber(numbers));
// Task 3
System.out.println(\"The average of numbers in the list is \"
+ averageOfNumbers(numbers));
// Task 4: Extra Credit. Uncomment the following
// two lines if you complete this task.
System.out.println(\"The list of unique numbers is:\");
uniqueNumbers(numbers);
}
private static void uniqueNumbers(int[] numbers) {
for (int i = 0; i < numbers.length; i++) {
boolean isDuplicate = false;
for (int j = 0; j < i; j++) {
if (numbers[i] == numbers[j]) {
isDuplicate = true;
break;
}
}
if (!isDuplicate) {
System.out.print(numbers[i] + \" \");
}
}
}
public static void printNumbers(int[] list) {
for (int i = 0; i < list.length; i++) {
System.out.print(list[i] + \" \");
}
System.out.println();
}
// 1. Write a method called smallestNumber that
// takes an int array as parameter, and returns the
// smallest number
public static int smallestNumber(int[] list) {
int small = 100;
for (int i = 0; i < list.length; i++) {
if (list[i] < small) {
small = list[i];
}
}
return small;
}
// 2. Write a method called largestNumber that
// takes an int array as parameter, and returns the
// largest number
public static int largestNumber(int[] list) {
int large = 0;
for (int i = 0; i < list.length; i++) {
if (list[i] > large) {
large = list[i];
}
}
return large;
}
// 3. Write a method called averageOfNumbers that
// takes an int array as parameter, and returns the
// average of the numbers
public static double averageOfNumbers(int[] list) {
double average = 0.0;
for (int i = 0; i < list.length; i++) {
average = average + list[i];
}
average = average / list.length;
return average;
}
public static boolean isPresent(int[] list, int target) {
boolean found = false;
for (int i = 0; i < list.length && !found && list[i] != 0; i++) {
if (list[i] == target) {
found = true;
}
}
return found;
}
}
output
The list is:
16 14 11 31 7 8 18 49 27 43 9 39 38 18 6 16 8 30 32 15
The smallest number in the list is 6
The largest number in the list is 49
The average of numbers in the list is 21.75
The list of unique numbers is:
16 14 11 31 7 8 18 49 27 43 9 39 38 6 30 32 15.
Getting StartedCreate a class called Lab8. Use the same setup for .pdfinfo309708
Getting Started
Create a class called Lab8. Use the same setup for setting up your class and main method as you
did for the previous assignments. Be sure to name your file Lab8.java. Additionally, make
another file called Arrays.java. This file will be an object, so simply start it off by declaring an
Arrays class. You can copy the following skeleton and fill in the appropriate code below each of
the comments:
public class Arrays {
/ Instance Variables
// Constructors
// findMin 1
// findMax
// calcSum
// calcAverage
// toString
}
Task Overview
Your task for this lab is to create a class called Arrays with some array processing methods. This
class will maintain an array and the number of elements present in it. Additionally, methods will
be available to display the current min and max elements along with the average of all of them.
Finally, a toString() method will be available to cleanly display all the array elements. Finally,
you will write a simple driver class to test out the above Arrays class.
Part 1: Instance Variables for Arrays
The first thing to do for the Arrays class is to set up its instance variables. Declare the following
(private) instance variables:
• An int array called array ? this will be the array we will be writing methods for.
• An int called count - this represents the number of valid elements in the array.
Part 2:
Constructors for Arrays The Arrays class will have two constructors. The first constructor takes
the maximum size of the array as input as a parameter and initializes the array instance variable
appropriately. It also sets count to size. Finally, it will initialize all of the array elements to some
values between 0 and 10, inclusive. To create this constructor, follow these steps:
• Import java.util.Random to make use of the random number generator.
• Create a constructor with the following header: public Arrays(int size)
• Initialize your array variable and set its size to size (see the chart on page 252 for reference on
initializing arrays). Be very careful that you are setting the value of your array instance variable,
as opposed to creating a new variable called array.
• Set the value of the count variable to size because we will be populating the entire array.
• Copy the following code to the constructor in order to generate random values between 0 and
10, inclusive:
Random rand = new Random();
for (int i = 0; i < count; i++)
{
array[i] = (rand.nextInt(10));
}
Next, create another constructor with the following header: public Arrays(int[] arr). This
constructor will initialize the class by using the passed arr argument in order to fill its instance
variables. The following things need to be done inside of this constructor:
• Set the array variable equal to arr.
• Set the count variable equal to the length of the array.
Part 3: Displaying the Output findMin()
The first method of this class will search the array for the minimum element. Copy the following
code for the findMin method. Note how the count i.
Required to augment the authors Binary Search Tree (BST) code to .docxdebishakespeare
Required to augment the author's Binary Search Tree (BST) code to support these new operations. Method names below are merely suggestions. (The author’s class is attached separately in the file called “authordoc”. I just built a simple test tree in the author’s main method which can be used to test the various operations. )
1. AnyType nthElement(int n) -- returns the n-th element (starting from 1) of the in-order traversal of the BST.
2. int rank( AnyType x ) -- returns the "rank" of x. The rank of an element is its position (starting with 1) in an in-order traversal.
3. AnyType median( ) -- returns the median (middle) element in the BST. If the BST contains an even number of elements, returns the smaller of the two medians.
4. boolean isPerfect( ) -- returns true if the BST is a perfect binary tree.
5. boolean isComplete( ) -- returns true if the BST is a complete binary tree.
6. String toString( int nrLevels ) -- generates the level-order output described in the sample output below.
Most of these operations could easily be implemented by performing an in-order traversal inside the BST and perhaps placing the results in an ArrayList. However, such a method is extremely inefficient. Instead, we are going to achieve faster performance by "augmenting" the BST nodes. You will add a new private integer data member ("tree size") to the BinaryNode which stores the size of the tree rooted at that node (including the root). You must develop your own algorithms for these operations, but obviously you will use the new tree size data member to guide your search. Think before you code and think recursively!
These items cover those topics not addressed elsewhere in the project description. (R) indicates a requirement, (H) indicates a hint, and (N) indicates a note.
1. (R) Although we are only using the BST for integers, the BST must remain a generic class.
2. (R) Duplicate values are not allowed. Attempts to insert a duplicate value should be ignored.
3. (R) Attempts to remove non-existent values should be ignored.
4. (R) From a coding perspective, the easiest way to avoid duplicate insertions or attempting to remove non-existent elements is to first call find( ). However, this technique is NOT permitted for two reasons.
Calling find( ) before each insert/remove doubles the running time for these operations and is therefore inefficient.
Recusively coding the insert/remove methods to handle these situations is a great learning experience.
5. (R) The level order print (PRINT command) outputs the value of each node, the size of the tree rooted at that node, and the value of the node's parent in that order, inside parenthesis, separated by commas. (node value, tree size, parent value). Since the root has no parent, print NULL for the root's parent value. For readability, separate the levels with a blank line and print no more than 6 node/size/parent values per line. If a level requires multiple lines, use consecutive lines (without a blank line between the ...
I am stuck on parts E and FExercise 1 NumberListTester.java.pdfRAJATCHUGH12
I am stuck on parts E and F
Exercise 1: NumberListTester.java
Class NumberList implements a simple list of Integers, using an ArrayList. NumberListTester
generates 10 random, positive, 2-digit ints, and adds them to the list. It then calls method
printList which prints the items on the list.
Run the program until you understand what it does.
a. Write the body of the method printReversed, which prints the list items in reverse order. Add a
statement in main to call printReversed after the call to printList.
Check ______
b. Write the body of the method printEveryOther, which prints every other item on the list,
beginning with the first one. In main, replace the statement that calls printReversed with one
that calls printEveryOther.
Check ______
c. Write the body of the method printEvens, which prints all the even-numbered ints on the list.
In main, replace the statement that calls printEveryOther with one that calls printEvens.
Check ______
All this printing is getting a bit tedious. Let\'s try some more fun operations.
d. 0. Add a new ArrayList-of-integer instance variable called bigList to the NumberList class
Add a statement to the NumberList constructor that creates an empty ArrayList object pointed to
by bigList
Delete the call to printEvens from main.
Write the body of the method splitList, which copies all ints that are greater than or equal to 50
from aList to bigList.
Add a method to the NumberList class to print bigList.
Add a sequence of method calls in main to verify that the splitList method is working correctly.
I.e., after calling splitList, call again the method that prints the original list and then call the
method you wrote in step 4 to print the bigList.
Check _____
E. Add a method insert to the NumberList class that takes two parameters of type int. The first
parameter is the index at which to insert a new number into the list, and the second is the number
to be inserted. E.g., if the first param is 4 and the second is 37, then 37 will be inserted at index
4 in aList (i.e., as the new 5th list element). The number inserted does not replace the number
currently at that position, but is inserted just before it.
Hint: The ArrayList class has a method that does exactly this. Call that method from your insert
method.
Now add statements to main to allow the user to specify the number to insert and the position at
which to insert it. Then, after inserting the new number, print the updated list.
Check _____
F. Finally, add code to your insert method that will assure that an IndexOutOfBoundsException
cannot be thrown. I.e., your insert method should just print an appropriate error message if the
first parameter --- the index at which to insert the new Integer --- is illegal.
Hint: What are the legal indices for an ArrayList? What is the smallest? What is the largest?
What about the special case of inserting a new value at the end of the list? Try it!
Check _____
MY CODE SO FAR:
import java.util.ArrayList ;
import java.util.Random ;
/.
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
2.(Sorted list: array implementation)This sorted list ADT discussed in class should be extended
by the addition of two new methods:
//Interface: ArrayListADT
//works for int
public interface ArrayListADT {
public boolean isEmpty(); //Method to determine whether the list is empty.
public boolean isFull(); //Method to determine whether the list is full.
public int listSize(); //Method to return the number of elements in the list.
public int maxListSize(); //Method to return the maximum size of the list.
public void print(); //Method to output the elements of the list.
public boolean isItemAtEqual(int location, int item); //Method to determine whether item is
the same as the item in the list at location.
public void insertAt(int location, int insertItem); //Method to insert insertItem in the list at
the position
public void insertEnd(int insertItem); //Method to insert insertItem at the end of the list.
public void removeAt(int location); //Method to remove the item from the list at location.
public int retrieveAt(int location); //Method to retrieve the element from the list at location.
public void replaceAt(int location, int repItem); //Method to replace the element in the list at
location with repItem.
public void clearList(); //Method to remove all the elements from the list.
public int search(int searchItem); //Method to determine whether searchItem is in the list.
public void remove(int removeItem); //Method to remove an item from the list.
}
//Class: ArrayListClass implements
//Interface: ArrayListADT
public abstract class ArrayListClass implements ArrayListADT {
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected int[] list; //array to hold the list elements
//Default constructor
public ArrayListClass() {
maxSize = 100;
length = 0;
list = new int[maxSize];
}
//Alternate Constructor
public ArrayListClass(int size) {
if(size <= 0) {
System.err.println(\"The array size must be positive. Creating an array of size 100.\");
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
}
public boolean isEmpty() {
return (length == 0);
}
public boolean isFull() {
return (length == maxSize);
}
public int listSize() {
return length;
}
public int maxListSize() {
return maxSize;
}
public void print() {
for (int i = 0; i < length; i++)
System.out.print(list[i] + \" \");
System.out.println();
}
public boolean isItemAtEqual(int location, int item) {
if (location < 0 || location >= length) {
System.err.println(\"The location of the item to be compared is out of range.\");
return false;
}
return list[location]== item;
}
public void clearList() {
for (int i = 0; i < length; i++)
list[i] = 0;
length = 0;
System.gc(); //invoke the Java garbage collector
}
public void removeAt(int location) {
if (location < 0 || location >= length)
System.err.println(\"The location of the item to be removed is out of range.\");
else {
for(int i = location; i < length - 1; i++)
list[i] .
Please add-modify the following to the original code using C# 1- Delet.docxStewartt0kJohnstonh
Pick any employer in Canada and you should pick employers in your familiar area if possible.
1. Summarize the benefits offered by both organizations.
2. Summarise the employee eligibility for both packages.
3. Compare and contrast the benefit packages.
In your opinion, which benefit package is more attractive? Why?
.
Write a method called uniqueNumbers that takes an int array as param.pdffashioncollection2
Write a method called uniqueNumbers that takes an int array as parameter, and returns a
different int array, which only contains the list of unique numbers in the original array. Hint: Use
the isPresent method defined below to accomplish your
here is the code we need to add too
Solution
solution
package com.mt.classes;
import java.util.ArrayList;
import java.util.List;
public class Lab8e {
public static void main(String[] args) {
int[] numbers = new int[20];
// Generate random numbers between 0 and 99 and fill up the array
for (int i = 0; i < numbers.length; i++) {
numbers[i] = (int) (Math.random() * 50);
}
System.out.println(\"The list is:\");
printNumbers(numbers);
// Task 1
System.out.println(\"The smallest number in the list is \"
+ smallestNumber(numbers));
// Task 2
System.out.println(\"The largest number in the list is \"
+ largestNumber(numbers));
// Task 3
System.out.println(\"The average of numbers in the list is \"
+ averageOfNumbers(numbers));
// Task 4: Extra Credit. Uncomment the following
// two lines if you complete this task.
System.out.println(\"The list of unique numbers is:\");
uniqueNumbers(numbers);
}
private static void uniqueNumbers(int[] numbers) {
for (int i = 0; i < numbers.length; i++) {
boolean isDuplicate = false;
for (int j = 0; j < i; j++) {
if (numbers[i] == numbers[j]) {
isDuplicate = true;
break;
}
}
if (!isDuplicate) {
System.out.print(numbers[i] + \" \");
}
}
}
public static void printNumbers(int[] list) {
for (int i = 0; i < list.length; i++) {
System.out.print(list[i] + \" \");
}
System.out.println();
}
// 1. Write a method called smallestNumber that
// takes an int array as parameter, and returns the
// smallest number
public static int smallestNumber(int[] list) {
int small = 100;
for (int i = 0; i < list.length; i++) {
if (list[i] < small) {
small = list[i];
}
}
return small;
}
// 2. Write a method called largestNumber that
// takes an int array as parameter, and returns the
// largest number
public static int largestNumber(int[] list) {
int large = 0;
for (int i = 0; i < list.length; i++) {
if (list[i] > large) {
large = list[i];
}
}
return large;
}
// 3. Write a method called averageOfNumbers that
// takes an int array as parameter, and returns the
// average of the numbers
public static double averageOfNumbers(int[] list) {
double average = 0.0;
for (int i = 0; i < list.length; i++) {
average = average + list[i];
}
average = average / list.length;
return average;
}
public static boolean isPresent(int[] list, int target) {
boolean found = false;
for (int i = 0; i < list.length && !found && list[i] != 0; i++) {
if (list[i] == target) {
found = true;
}
}
return found;
}
}
output
The list is:
16 14 11 31 7 8 18 49 27 43 9 39 38 18 6 16 8 30 32 15
The smallest number in the list is 6
The largest number in the list is 49
The average of numbers in the list is 21.75
The list of unique numbers is:
16 14 11 31 7 8 18 49 27 43 9 39 38 6 30 32 15.
Getting StartedCreate a class called Lab8. Use the same setup for .pdfinfo309708
Getting Started
Create a class called Lab8. Use the same setup for setting up your class and main method as you
did for the previous assignments. Be sure to name your file Lab8.java. Additionally, make
another file called Arrays.java. This file will be an object, so simply start it off by declaring an
Arrays class. You can copy the following skeleton and fill in the appropriate code below each of
the comments:
public class Arrays {
/ Instance Variables
// Constructors
// findMin 1
// findMax
// calcSum
// calcAverage
// toString
}
Task Overview
Your task for this lab is to create a class called Arrays with some array processing methods. This
class will maintain an array and the number of elements present in it. Additionally, methods will
be available to display the current min and max elements along with the average of all of them.
Finally, a toString() method will be available to cleanly display all the array elements. Finally,
you will write a simple driver class to test out the above Arrays class.
Part 1: Instance Variables for Arrays
The first thing to do for the Arrays class is to set up its instance variables. Declare the following
(private) instance variables:
• An int array called array ? this will be the array we will be writing methods for.
• An int called count - this represents the number of valid elements in the array.
Part 2:
Constructors for Arrays The Arrays class will have two constructors. The first constructor takes
the maximum size of the array as input as a parameter and initializes the array instance variable
appropriately. It also sets count to size. Finally, it will initialize all of the array elements to some
values between 0 and 10, inclusive. To create this constructor, follow these steps:
• Import java.util.Random to make use of the random number generator.
• Create a constructor with the following header: public Arrays(int size)
• Initialize your array variable and set its size to size (see the chart on page 252 for reference on
initializing arrays). Be very careful that you are setting the value of your array instance variable,
as opposed to creating a new variable called array.
• Set the value of the count variable to size because we will be populating the entire array.
• Copy the following code to the constructor in order to generate random values between 0 and
10, inclusive:
Random rand = new Random();
for (int i = 0; i < count; i++)
{
array[i] = (rand.nextInt(10));
}
Next, create another constructor with the following header: public Arrays(int[] arr). This
constructor will initialize the class by using the passed arr argument in order to fill its instance
variables. The following things need to be done inside of this constructor:
• Set the array variable equal to arr.
• Set the count variable equal to the length of the array.
Part 3: Displaying the Output findMin()
The first method of this class will search the array for the minimum element. Copy the following
code for the findMin method. Note how the count i.
Required to augment the authors Binary Search Tree (BST) code to .docxdebishakespeare
Required to augment the author's Binary Search Tree (BST) code to support these new operations. Method names below are merely suggestions. (The author’s class is attached separately in the file called “authordoc”. I just built a simple test tree in the author’s main method which can be used to test the various operations. )
1. AnyType nthElement(int n) -- returns the n-th element (starting from 1) of the in-order traversal of the BST.
2. int rank( AnyType x ) -- returns the "rank" of x. The rank of an element is its position (starting with 1) in an in-order traversal.
3. AnyType median( ) -- returns the median (middle) element in the BST. If the BST contains an even number of elements, returns the smaller of the two medians.
4. boolean isPerfect( ) -- returns true if the BST is a perfect binary tree.
5. boolean isComplete( ) -- returns true if the BST is a complete binary tree.
6. String toString( int nrLevels ) -- generates the level-order output described in the sample output below.
Most of these operations could easily be implemented by performing an in-order traversal inside the BST and perhaps placing the results in an ArrayList. However, such a method is extremely inefficient. Instead, we are going to achieve faster performance by "augmenting" the BST nodes. You will add a new private integer data member ("tree size") to the BinaryNode which stores the size of the tree rooted at that node (including the root). You must develop your own algorithms for these operations, but obviously you will use the new tree size data member to guide your search. Think before you code and think recursively!
These items cover those topics not addressed elsewhere in the project description. (R) indicates a requirement, (H) indicates a hint, and (N) indicates a note.
1. (R) Although we are only using the BST for integers, the BST must remain a generic class.
2. (R) Duplicate values are not allowed. Attempts to insert a duplicate value should be ignored.
3. (R) Attempts to remove non-existent values should be ignored.
4. (R) From a coding perspective, the easiest way to avoid duplicate insertions or attempting to remove non-existent elements is to first call find( ). However, this technique is NOT permitted for two reasons.
Calling find( ) before each insert/remove doubles the running time for these operations and is therefore inefficient.
Recusively coding the insert/remove methods to handle these situations is a great learning experience.
5. (R) The level order print (PRINT command) outputs the value of each node, the size of the tree rooted at that node, and the value of the node's parent in that order, inside parenthesis, separated by commas. (node value, tree size, parent value). Since the root has no parent, print NULL for the root's parent value. For readability, separate the levels with a blank line and print no more than 6 node/size/parent values per line. If a level requires multiple lines, use consecutive lines (without a blank line between the ...
I am stuck on parts E and FExercise 1 NumberListTester.java.pdfRAJATCHUGH12
I am stuck on parts E and F
Exercise 1: NumberListTester.java
Class NumberList implements a simple list of Integers, using an ArrayList. NumberListTester
generates 10 random, positive, 2-digit ints, and adds them to the list. It then calls method
printList which prints the items on the list.
Run the program until you understand what it does.
a. Write the body of the method printReversed, which prints the list items in reverse order. Add a
statement in main to call printReversed after the call to printList.
Check ______
b. Write the body of the method printEveryOther, which prints every other item on the list,
beginning with the first one. In main, replace the statement that calls printReversed with one
that calls printEveryOther.
Check ______
c. Write the body of the method printEvens, which prints all the even-numbered ints on the list.
In main, replace the statement that calls printEveryOther with one that calls printEvens.
Check ______
All this printing is getting a bit tedious. Let\'s try some more fun operations.
d. 0. Add a new ArrayList-of-integer instance variable called bigList to the NumberList class
Add a statement to the NumberList constructor that creates an empty ArrayList object pointed to
by bigList
Delete the call to printEvens from main.
Write the body of the method splitList, which copies all ints that are greater than or equal to 50
from aList to bigList.
Add a method to the NumberList class to print bigList.
Add a sequence of method calls in main to verify that the splitList method is working correctly.
I.e., after calling splitList, call again the method that prints the original list and then call the
method you wrote in step 4 to print the bigList.
Check _____
E. Add a method insert to the NumberList class that takes two parameters of type int. The first
parameter is the index at which to insert a new number into the list, and the second is the number
to be inserted. E.g., if the first param is 4 and the second is 37, then 37 will be inserted at index
4 in aList (i.e., as the new 5th list element). The number inserted does not replace the number
currently at that position, but is inserted just before it.
Hint: The ArrayList class has a method that does exactly this. Call that method from your insert
method.
Now add statements to main to allow the user to specify the number to insert and the position at
which to insert it. Then, after inserting the new number, print the updated list.
Check _____
F. Finally, add code to your insert method that will assure that an IndexOutOfBoundsException
cannot be thrown. I.e., your insert method should just print an appropriate error message if the
first parameter --- the index at which to insert the new Integer --- is illegal.
Hint: What are the legal indices for an ArrayList? What is the smallest? What is the largest?
What about the special case of inserting a new value at the end of the list? Try it!
Check _____
MY CODE SO FAR:
import java.util.ArrayList ;
import java.util.Random ;
/.
2.(Sorted list array implementation)This sorted list ADT discussed .pdfarshin9
2.(Sorted list: array implementation)This sorted list ADT discussed in class should be extended
by the addition of two new methods:
//Interface: ArrayListADT
//works for int
public interface ArrayListADT {
public boolean isEmpty(); //Method to determine whether the list is empty.
public boolean isFull(); //Method to determine whether the list is full.
public int listSize(); //Method to return the number of elements in the list.
public int maxListSize(); //Method to return the maximum size of the list.
public void print(); //Method to output the elements of the list.
public boolean isItemAtEqual(int location, int item); //Method to determine whether item is
the same as the item in the list at location.
public void insertAt(int location, int insertItem); //Method to insert insertItem in the list at
the position
public void insertEnd(int insertItem); //Method to insert insertItem at the end of the list.
public void removeAt(int location); //Method to remove the item from the list at location.
public int retrieveAt(int location); //Method to retrieve the element from the list at location.
public void replaceAt(int location, int repItem); //Method to replace the element in the list at
location with repItem.
public void clearList(); //Method to remove all the elements from the list.
public int search(int searchItem); //Method to determine whether searchItem is in the list.
public void remove(int removeItem); //Method to remove an item from the list.
}
//Class: ArrayListClass implements
//Interface: ArrayListADT
public abstract class ArrayListClass implements ArrayListADT {
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected int[] list; //array to hold the list elements
//Default constructor
public ArrayListClass() {
maxSize = 100;
length = 0;
list = new int[maxSize];
}
//Alternate Constructor
public ArrayListClass(int size) {
if(size <= 0) {
System.err.println(\"The array size must be positive. Creating an array of size 100.\");
maxSize = 100;
}
else
maxSize = size;
length = 0;
list = new int[maxSize];
}
public boolean isEmpty() {
return (length == 0);
}
public boolean isFull() {
return (length == maxSize);
}
public int listSize() {
return length;
}
public int maxListSize() {
return maxSize;
}
public void print() {
for (int i = 0; i < length; i++)
System.out.print(list[i] + \" \");
System.out.println();
}
public boolean isItemAtEqual(int location, int item) {
if (location < 0 || location >= length) {
System.err.println(\"The location of the item to be compared is out of range.\");
return false;
}
return list[location]== item;
}
public void clearList() {
for (int i = 0; i < length; i++)
list[i] = 0;
length = 0;
System.gc(); //invoke the Java garbage collector
}
public void removeAt(int location) {
if (location < 0 || location >= length)
System.err.println(\"The location of the item to be removed is out of range.\");
else {
for(int i = location; i < length - 1; i++)
list[i] .
package singlylinkedlist; public class Node { public String valu.pdfamazing2001
package singlylinkedlist;
public class Node {
public String value;
public Node next;
public Node(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
SingleyLinkedList.java :
package singlylinkedlist;
import java.io.*;
import java.util.*;
/**
* Defines the interface for a singly-linked list.
*
*/
public interface SinglyLinkedList {
/**
* @return Reference to the first node. If the list is empty, this method
* returns null.
*/
public Node getFirst();
/**
* @return Reference to the last node . If the list is empty, this method
* returns null.
*/
public Node getLast();
/**
* @return Number of nodes in the list
*/
public int size();
/**
* @return true if the list has no nodes; false otherwise
*/
public boolean isEmpty();
/**
* Removes all nodes in the list.
*/
public void clear();
/**
* Inserts a new node with the given value after cursor.
*
* @param cursor
* The node to insert after. Set this to null to insert value as
the
* new first Node.
* @param value
* The value to insert
* @return a reference to the newly inserted Node
*/
public Node insert(Node cursor, String value);
/**
* Inserts a new node with the given value at the "end" of the list.
*
* @param value
* @return a reference to the newly inserted Node
*/
public Node append(String value);
/**
* Removes the node after the specified Node (cursor) from the list.
*
* @param cursor
* A reference to the Node to remove.
*/
public void removeAfter(Node cursor);
/**
* Returns a reference to the first Node containing the key, starting from
the
* given Node.
*
* @param start
* @param key
* @return a reference to the first Node containing the key
*/
public Node find(Node start, String key);
/**
* Prints the values of all the items in a list
*/
public void printWholeList();
}
SinglyLinkedTester.java:
package sbccunittest;
import static java.lang.Math.*;
import static java.lang.System.*;
import static org.apache.commons.lang3.StringUtils.*;
import static org.junit.Assert.*;
import static sbcc.Core.*;
import java.io.*;
import java.lang.reflect.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.lang3.*;
import org.junit.*;
import org.w3c.dom.ranges.*;
import sbcc.*;
import singlylinkedlist.*;
/**
* 09/16/2021
*
* @author sstrenn
*
*/
public class SinglyLinkedListTester {
public static String newline = System.getProperty("line.separator");
public static int totalScore = 0;
public static int extraCredit = 0;
public static boolean isZeroScore = false;
public static String scorePreamble = "";
@BeforeClass
public static void beforeTesting() {
totalScore = 0;
extraCredit = 0;
}
@AfterClass
public static void afterTesting() {
if (isZeroScore) {
totalScore = 0;
extraCredit = 0;
}
println(scorePreamble + "Estimated score (w/o late penalties, etc.) is:
" + totalScore + " out of 25.");
// If the project follows the naming convention, save the results in a
folder on
// the desktop. (Alex Kohanim)
try {
String directory =
substri.
Java Programming- 1) Write a recursive method that finds and returns t.docxmichael1810
Java Programming:
1) Write a recursive method that finds and returns the sum of the elements in an int array. Also, write a program to test your method
** Please simple enough for a beginner to understand
Solution
/**
* @author
*
*/
public class RecusrsiveArraySum {
/**
* @param args
*/
public static void main(String[] args) {
int arr[] = { 3, 4, 6, 7 };
System.out
.println(\"Sum of array Elements: \" + sum(arr, arr.length - 1));
}
/**
* recursive sum of array elements
*
* @param array
* @param index
* @return
*/
public static int sum(int[] array, int index) {
// if array is empty
if (index < 0)
return 0;
if (index == 0) {
// when no index reaches first element
return array[0];
} else {
// adding array elements
return array[index] + sum(array, index - 1);
}
}
}
OUTPUT:
Sum of array Elements: 20
.
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
Create a menu-driven program that will accept a collection of non-negative integers from the
keyboard, calculate the mean and median values and display those values on the screen. Your
menu should have 6 options: 1. Add a number to the array 2. Display the mean 3. Display the
median 4. Print the array to the screen 5. Print the array in reverse order 6. Quit
Program particulars: Use an array of type int to store the integers entered by the user. There
must be error checking on the input integer. If it is negative, the program will print an error
message and re-prompt. This process will continue until a non-negative integer is entered. You
must use a try-catch structure to trap both types of input errors (like letters where numbers
should go) and range errors (like -1). You must write your own selectionSort utility method to
sort your array. Place the method in an external file named SortSearchUtil.java. There must be
error checking on the menu choice entered. If the user enters a choice not on the menu, the
program will print an error message, re-display the menu and re-prompt. This process will
continue until a valid option value is entered. Your solution must be modular. The design of your
methods is up to you, but the rules of “highly cohesive” and “loosely coupled” must be followed.
Your program should be well-documented. Explain what you’re doing in your code. Be sure to
include the usual name and assignment notes. Note your program will have to sort your array
before you can find the median. Include your SortSearchUtil.java file which will contain your
sort method.
This is what my project looks like already: Please fix it thanks. The SortSearchUtil will also be
included.
import java.util.Scanner;
public class ArraySorting
{
public static void main(String[] args)
{
int option;
int integer = 0;
int optionOne;
int optionTwo;
int optionThree;
int optionFour;
int optionFive;
int[] numbers = new int[5];
Scanner kb = new Scanner(System.in);
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
while((integer < 0))
{
System.out.println(\"I am sorry that is not a non-negative integer.\");
System.out.println(\"\");
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
}
option = displayMenu(kb);
while (option != 6)
{
switch (option)
{
case 1:
optionOne(numbers);
System.out.println(\"\");
break;
case 2:
optionTwo(numbers);
System.out.println(\"\");
case 3:
//optionThree();
System.out.println(\"\");
break;
case 4:
//optionFour();
System.out.println(\"\");
break;
case 5:
//optionFive();
System.out.println(\"\");
break;
}
option = displayMenu(kb);
}
if (option == 6)
{
System.out.println();
System.out.println(\"Thank you. Have a nice day.\");
}
}
private static int displayMenu(Scanner kb)
{
int option = 0;
while (option != 1 && option != 2 && option != 3 && option != 4 && option !=5 && option
!=6)
{
System.out.println(\"\\t\\t1. Add a number to the array\ \\t\\t2. Display the mean\ \\t\.
week4_src/ArrayMethods.javaweek4_src/ArrayMethods.javapackage edu.drexel.ct290;
publicclassArrayMethods{
/**
* Pass and array to a method that will search through it for a given value.
*
* @param elementToFind: This is the item we want to find in the array.
* @param stringArray: This is the array to search through.
* @return Returns: The index of the element, or -1 if not found.
*/
publicint findElement(String elementToFind,String[] stringArray ){
int index =-1;
for(int i=0; i<stringArray.length; i++){
if( elementToFind.equals(stringArray[i])){
// If the element is found, set index
index = i;
}
}
return index;
}
/**
* Replace a value in an array.
*
* @param indexToReplace: The index where the new value should be written.
* @param newValue: The new value.
* @param stringArray: Change a value in this array.
* @return True if the given index is valid
*/
publicboolean replace(int indexToReplace,String newValue,String[] stringArray ){
boolean replaced =false;
// Use the if condition to make sure the given index is valid
if( indexToReplace >0&& indexToReplace < stringArray.length ){
stringArray[indexToReplace]= newValue;
replaced =true;
}
return replaced;
}
/**
* Insert a value into the array. From the insertion point on, the
* data needs to be copied down one space to make room for the new
* element indices .
*
* @param index: The index where the new element should be inserted
* @param element: The element to insert in the array
* @param array: The array to insert into
* @param indicesUsed: the number of elements in the array already used
* @return the array with the new value inserted
*/
publicString[] insert(int index,String element,String[] array,int indicesUsed){
// First, check that there is enough room in the array for
// another element. The parameter indicesUsed indicates how
// many elements of the array are already filled.
String[] newArray = array;
if( indicesUsed == array.length ){
newArray = makeBiggerArray(array);
}
// Now that we know there is enough room, move the
// elements down one spot in the array until we get to the
// insertion point. Make sure the element at the insertion
// point gets moved too.
int indexToMove = indicesUsed;
while( indexToMove >= index ){
newArray[indexToMove+1]= newArray[indexToMove];
indexToMove--;
}
// Set the given index to the new element
newArray[index]= element;
// Return the new array
return newArray;
}
/**
* Since arrays are fixed size, if you run out of room, the
* only options is to create a new bigger array, then copy
* the old data over.
* @param oldArray: The old data to copy into the new array
* @return The new bigger array
*/
publicString[] makeBiggerArray(String[] oldArray){
// Make the new array twice the size of the old one.
int newArraySize .
ReversePoem.java ---------------------------------- public cl.pdfravikapoorindia
ReversePoem.java :-
---------------------------------
public class ReversePoem {
/*This programs has you display a pessimistic poem from a list of phrases*/
// and then reverse the phrases to find another more optimistic poem.
public static void main(String[] args) throws Exception
{
//Queue object
MyQueue queue = new MyQueue<>();
//Stack object
MyStack stack = new MyStack<>();
//String buffer to apppend all Strings
StringBuffer sb = new StringBuffer();
// Create a single String object from the 16 Strings below
String set1 = \"I am part of a lost generation#and I refuse to believe that#\";
sb.append(set1);
String set2 = \"I can change the world#I realize this may be a shock but#\";
sb.append(set2);
String set3 = \"\'Happiness comes from within\'#is a lie, and#\";
sb.append(set3);
String set4 = \"\'Money will make me happy\'#So in 30 years I will tell my children#\";
sb.append(set4);
String set5 = \"they are not the most important thing in my life#\";
sb.append(set5);
String set6 = \"My employer will know that#I have my priorities straight because#\";
sb.append(set6);
String set7 = \"work#is more important than#family#I tell you this#\";
sb.append(set7);
String set8 = \"Once upon a time#Families stayed together#\";
sb.append(set8);
String set9 = \"but this will not be true in my era#\";
sb.append(set9);
String set10 = \"This is a quick fix society#Experts tell me#\";
sb.append(set10);
String set11 = \"30 years from now, I will be celebrating the 10th anniversary of my
divorce#\";
sb.append(set11);
String set12 = \"I do not concede that#I will live in a country of my own making#\";
sb.append(set12);
String set13 = \"In the future#Environmental destruction will be the norm#\";
sb.append(set13);
String set14 = \"No longer can it be said that#My peers and I care about this earth#\";
sb.append(set14);
String set15 = \"It will be evident that#My generation is apathetic and lethargic#\";
sb.append(set15);
String set16 = \"It is foolish to presume that#There is hope#\";
sb.append(set16);
String finalString = sb.toString();
String itmes[] = finalString.split(\"#\");
System.out.println(\"========== Original Phrase ==============\");
for(int i = 0 ; i < itmes.length;i++){
queue.enqueue(itmes[i]);
System.out.println(itmes[i]);
}
for(int i = 0 ; i < itmes.length;i++){
stack.push(queue.dequeue());
}
System.out.println(\"========== Reverse Phrase ==============\");
for(int i = 0 ; i < itmes.length;i++){
System.out.println(stack.pop());
}
/* You are given a list of phrases in Strings; the phrases
are separated by pound signs: \'#\':
1. Create a single String object from this list.
2. Then, split the String of phrases into an array of
phrases using the String split method.
3. Display a poem by walking through the array and
displaying each phrase one per line.
4. And, at the same time, place each phrase on a
MyQueue object using only the enqueue method.
5. After all the phrases have been placed on the queue,
transfer the phrases from the MyQueue object to a
MyS.
java I am trying to run my code but it is not letting me .pdfadinathassociates
java
I am trying to run my code but it is not letting me i dont know what i should do or fix. Thank you so
much for your help. This is the problem and my code will be on the bottom.
Problem #1 and Only
Dynamic Array of Integers Class
Create a class named DynamicArray that will have convenient functionality similar to JavaScripts
Array object and Javas ArrayList class. The class allows to store array of integers that can grow
and shrink as needed, search for values, remove elements, etc.
You are not allowed to use ArrayList object as well as any methods from java.util.Arrays
class.
Please see the list of required features and methods below.
private int array[] You MUST store the data internally in a regular partially-filled array of integers.
Please DO NOT USE ArrayList. The size of the allocated array is its capacity and will be
discussed below.
private int size. This variable stores the number of occupied elements in the array. Set to 0 in the
constructor.
Constructor with parameter. The parameter defines the capacity (length) of initial array. Allocates
array of given capacity (length), sets size field to 0. In case the parameter given to constructor is 0
or negative, IllegalArgumentException is being thrown.
No-argument constructor. Allocates array of length 3, assigns it to the array field, sets size field to
0.
Copy constructor. The constructor takes an object of type DynamicArray as a parameter and
copies it into the object it creates. The constructor throws IllegalArgumentException if the object
that was passed to copy from is null.
int getSize() returns the number of occupied elements in the array.
int getCapacity() returns the actual size (length) of the partially-filled array
int [] getArray() accessor returns the entire partially-filled array. Make sure you DO NOT return the
private array field, make a copy of it.
int [] toArray() accessor returns an occupied part of the partially-filled array. Make sure you DO
NOT return the private array field. Instead, allocate memory for the new array, copy the occupied
portion of the field into that new object, and return the new array.
public void push(int num) adds a new element to the end of the array and increments the size
field. If the array is full, you need to increase the capacity of the array:
Create a new array with the size equal to double the capacity of the original one.
Copy all the elements from the array field to the new array.
Add the new element to the end of the new array.
Use new array as an array field.
Make sure your method works well when new elements are added to an empty DynamicArray.
public int pop() throws RuntimeException removes the last element of the array and returns it.
Decrements the size field. If the array is empty a RuntimeException with the message Array is
empty must be thrown. At this point check the capacity of the array. If the capacity is 4 times larger
than the number of occupied elements (size), it is time to shrink the array:
Create a new array wi.
File LinkedList.java Defines a doubly-l.pdfConint29
File: LinkedList.java
/**
* Defines a doubly-linked list class
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
/**
* Returns the value stored in the first node
* @precondition
* @return the value stored at node first
* @throws NoSuchElementException
*/
public T getFirst() throws NoSuchElementException {
return null;
}
/**
* Returns the value stored in the last node
* @precondition
* @return the value stored in the node last
* @throws NoSuchElementException
*/
public T getLast() throws NoSuchElementException {
return null;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
return null;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return -1;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return false;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return false;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition
*/
public void addFirst(T data) {
return;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition
*/
public void addLast(T data) {
return;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
return;
}
/**
* removes the element at the front of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeFirst() throws NoSuchElementException {
return;
}
/**
* removes the element at the end of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeLast() throws NoSuchElementException {
return;
}
/**
* removes the element referenced by the iterator
* @precondition
* @pos.
Please help solve this in C++ So the program is working fin.pdfankit11134
Please help solve this in C++. So the program is working fine but when submitting it, it gives me a
code -11, and I believe the problem is that after inserting the numbers it removes them one by one
until the last in the list, and when it tries to remove the last number in the list that is when it
counters the problem. Below is the full code but you just need to change something in the
SortedNumberList.h file under the bool remove function.
4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on
the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: - a double data value, - a pointer to the next node, and - a pointer to the
previous node. Each member variable is protected. So code outside of the class must use the
provided getter and setter member functions to get or set a member variable. Node.h is read only,
since no changes are required. Step 2: Implement the Insert() member function A class for a
sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList
class's Insert() member function. The function must create a new node with the parameter value,
then insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after
inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove(0 member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is
841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after
inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after
removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents
after each insertion sortedNumberList list; for (auto term : terms) { doubl.
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfaloeplusint
Step 1:You need to run the JAVA programs in sections 3.3 and 3.5 for selection sort and
insertion sort. You need to attach the output results.
Step 2: You need to modify these two programs, save them, submit them, and add some
comments and explanations to them to sort the list elements from high to low value. The index
should be IndexHighest instead IndexSmallest.
Step3: Run the modified programs and print out the results and submit them.
In the end, you need the running results for original JAVA programs (selection and insertion sort
JAVA programs), the two modified programs to sort the values from high to low value for
selection and insertion sorts, and the results for the modified programs.
This program uses the selection sort algorithm to sort an array. The code has been modified to
also calculate how many item comparisons are done. You can try running the program with
different arrays to see how the total number of comparisons changes (or doesn't change).
CODE 3.3 ---
import java.util.Arrays;
public class SelectionSortDemo {
private static int selectionSort(int[] numbers) {
// A variable to hold the number of item comparisons
int comparisons = 0;
for (int i = 0; i < numbers.length - 1; i++) {
// Find index of smallest remaining element
int indexSmallest = i;
for (int j = i + 1; j < numbers.length; j++) {
comparisons++;
if (numbers[j] < numbers[indexSmallest]) {
indexSmallest = j;
}
}
// Swap numbers[i] and numbers[indexSmallest]
int temp = numbers[i];
numbers[i] = numbers[indexSmallest];
numbers[indexSmallest] = temp;
}
return comparisons;
}
public static void main(String[] args) {
// Create an array of numbers to sort
int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 };
// Display the contents of the array
System.out.println("UNSORTED: " + Arrays.toString(numbers));
// Call the selectionSort method
int comparisons = selectionSort(numbers);
// Display the sorted contents of the array
System.out.println("SORTED: " + Arrays.toString(numbers));
System.out.println("Total comparisons: " + comparisons);
}
}
CODE 3.5 ---
import java.util.Arrays;
public class InsertionSortDemo {
private static void insertionSort(int[] numbers) {
for (int i = 1; i < numbers.length; i++) {
int j = i;
while (j > 0 && numbers[j] < numbers[j - 1]) {
// Swap numbers[j] and numbers [j - 1]
int temp = numbers[j];
numbers[j] = numbers[j - 1];
numbers[j - 1] = temp;
j--;
}
}
}
public static void main(String[] args) {
// Create an array of numbers to sort
int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 };
// Display the contents of the array
System.out.println("UNSORTED: " + Arrays.toString(numbers));
// Call the insertionSort method
insertionSort(numbers);
// Display the sorted contents of the array
System.out.println("SORTED: " + Arrays.toString(numbers));
}
}.
Everything needs to be according to the instructions- thank you! SUPPO.pdffirstchoiceajmer
Everything needs to be according to the instructions, thank you!
SUPPORTING CODE:
MyList.java
/**
This interface specifies the basic operations of any list-like object.
This interface contains a variation of the methods of the
standard java.util.List interface.
*/
public interface MyList {
/**
Adds an element at the end of the list.
*/
public void addToEnd(Object o);
/**
Inserts an element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void insertAt(int index, Object o);
/**
Removes the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void removeAt(int index);
/**
Returns the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public Object getAt(int index);
/**
Returns the size of the list.
@return the number of elements in the list
*/
public int getSize();
/**
Returns a list iterator for this list.
@return a list iterator for this list
*/
public MyListIterator getIterator();
}
MyListIterator.java
/**
A list iterator allows access of a position in a list.
This interface contains a subset of the methods of the
standard java.util.ListIterator interface. The methods for
backward traversal are not included.
*/
public interface MyListIterator
{
/**
Moves the iterator past the next element.
@return the traversed element
*/
Object next();
/**
Tests if there is an element after the iterator
position.
@return true if there is an element after the iterator
position
*/
boolean hasNext();
}
Main.java
// you may use this file to write and run code to test your MyArrayList class
public class Main {
public static void main(String[] args) {
}
}
FILE THAT NEEDS THAT NEEDS CODE:
MyArrayList.java
// Complete the implementation of your MyArrayList class in this file
public class MyArrayList implements MyList {
// Implement the required fields and methods here
private int capacity = 8;
private Object[ ] array = new Object [capacity];
private int size = 0;
@Override
public void add(Object o) {
if (size >= capacity){
Object[] temp = new Object[2*array.length];
for(int i=0;i<size;++i){
temp[i] = array[i];
}
this.capacity = 2*array.length;
array = temp;
array[size++] = o;
return;
}
else
{
array[size++] = o;
}
}
@Override
public int size() {
return size;
}
@Override
public Object at(int index) {
if (index >= capacity)
return null;
else
return array[index];
}
@Override
public void insertAt(int index, Object o) {
if (index >= capacity)
return;
else
{
size++;
for (int x = size - 1; x > index; x--) {
array[x] = array[x - 1];
}
array[index] = o;
}
}
@Override
public void removeAt(int index) {
if (index >= size || size == 0)
return;
else {
Object e = array[index];
for (int x = index; x < this.array.length - 1; x++) {
array[x] = array[x + 1];
}
size--;
}
}
public void ensureCapacity(int minCapacity) {
}
public void trimToSize() {
ensureCapacity(size);
}
// Do not alter the code below
@Override
public MyListIterator getIterator() {
return new MyA.
Labprogram.java
LinkedList.java
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
*
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
*
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
public T getFirst() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
public T getLast() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
public T getIterator() throws NullPointerException {
if (iterator != null) {
return iterator.data;
} else {
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
public int getLength() {
return length;
}
public boolean isEmpty() {
return length == 0;
}
public boolean offEnd() {
return iterator == null;
}
public void addFirst(T data) {
Node newNode = new Node(data);
if (isEmpty()) {
first = newNode;
last = newNode;
} else {
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
public void addLast(T data) {
Node newNode = new Node(data);
if (isEmpty()) {
first = newNode;
last = newNode;
} else {
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
public void addIterator(T data) throws NullPointerException {
if (offEnd()) {
throw new NullPointerException("addIterator Iterator is off end.");
}
if (iterator == last) {
addLast(data);
} else {
Node newNode = new Node(data);
Node next = iterator.next;
newNode.next = next;
newNode.prev = iterator;
iterator.next = newNode;
next.prev = newNode;
length++;
}
}
public void removeFirst() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
if (length == 1) {
first = null;
last = null;
iterator = null;
} else {
if (iterator == first) {
iterator = null;
}
first = first.next;
first.prev = null;
}
length--;
}
public void removeLast() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
if (length == 1) {
first = null;
last = null;
iterator = null;
} else {
if (iterator == last) {
iterator = null;
}
last = last.prev;
last.next = null;
}
length--;
}
public void removeIterator() throws NullPointerException {
if (offEnd()) {
throw new NullPointerException("Iterator is off the end opf the list.");
}
if (iterator .
MinOfFourNumbers.javaimport java.util.Scanner;public class MinOf.pdfaptex1
If I assume you meant supply is determined as [q_(s)=3p^2-4p] and demand is determined as
[q_(d)=-p^2+24] then I would calculate that the equilibrium is where [q_(s)=q_(d)] and p>0. So I
set up the equation [3p^2-4p=-p^2+24] I add [p^2] to both sides of the equation yielding [4p^2-
4p=24] I subtract 24 from each side, yielding the quadratic equation [4p^2-4p-24=0] I factor the
equation [(2p-6)(2p+4)=0] so that means [2p-6=0] or [2p+4=0] In the former case 2p=6 so p=3,
and in the latter 2p=-4 so p=-2. The economic nature of the question requires p>0, so [p!=-2] and
thus the equilibrium price is $3.00 each. Then to determine the equilibrium quantity, we solve
either q expression for p=3.
[q_(s)=3(3)^2-4(3)=3(9)-12=27-12=15]
[q_(d)=-(3^2)+24=-9+24=15]
So the equilibrium quantity is 15 items.
The price and quantity for market equilibrium is 15 items at $3.00 each.
Solution
If I assume you meant supply is determined as [q_(s)=3p^2-4p] and demand is determined as
[q_(d)=-p^2+24] then I would calculate that the equilibrium is where [q_(s)=q_(d)] and p>0. So I
set up the equation [3p^2-4p=-p^2+24] I add [p^2] to both sides of the equation yielding [4p^2-
4p=24] I subtract 24 from each side, yielding the quadratic equation [4p^2-4p-24=0] I factor the
equation [(2p-6)(2p+4)=0] so that means [2p-6=0] or [2p+4=0] In the former case 2p=6 so p=3,
and in the latter 2p=-4 so p=-2. The economic nature of the question requires p>0, so [p!=-2] and
thus the equilibrium price is $3.00 each. Then to determine the equilibrium quantity, we solve
either q expression for p=3.
[q_(s)=3(3)^2-4(3)=3(9)-12=27-12=15]
[q_(d)=-(3^2)+24=-9+24=15]
So the equilibrium quantity is 15 items.
The price and quantity for market equilibrium is 15 items at $3.00 each..
OrderTest.javapublic class OrderTest { Get an arra.pdfakkhan101
OrderTest.java
public class OrderTest {
/**
* Get an array of specified size and pass it to Order.order().
* Report the results.
*/
public static void main(String[] args) {
if (args.length != 1) {//1
System.out.println(\"Usage: java OrderTest sizeOfArray\ \"
+ \"\\tor\ \\tjava OrderTest arrayFile\");
System.exit(1);
}
// create or read the int[]
int size = 0;
int[] array = new int[0];//5
try {
size = Integer.parseInt(args[0]);
array = ArrayOfInts.randomizedArray(size);
} catch (NumberFormatException nfe) {//8
try {
array = ArrayOfInts.arrayFromFile(args[0]);
size = array.length;
} catch (Exception e) {
System.err.println(\"unable to read array from \" + args[0]);
System.exit(1);//14
}
}
System.out.println(\"before:\");//15
for (int i = 0; i < array.length; i++) {//2 n
System.out.printf(((i+1) % 10 > 0) ? \" %d\" : \" %d\ \", array[i]);//1
}
int myNum = Order.order(array); //this is the call we want to measure
System.out.println(\"\ after:\");//18
for (int i = 0; i < array.length; i++) {//2 n
System.out.printf(((i+1) % 10 > 0) ? \" %d\" : \" %d\ \", array[i]);
}
System.out.println(myNum);
}
}
ArrayOfInts.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.Scanner;
public class ArrayOfInts {
/**
* Returns an array of consecutive ints from 1 to size.
*/
public static int[] orderedArray(int size) {
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = i+1;
}
return a;
}
/**
* Returns a randomized array containing ints from 1 to size.
*/
public static int[] randomizedArray(int size) {
ArrayList aL = new ArrayList();
for (int i = 0; i < size; i++) {
aL.add(i+1);
}
Collections.shuffle(aL);
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = aL.get(i);
}
return a;
}
/**
* Writes an int[] to a plain-text file with ints separated by spaces.
* Useful for creating input files for repeatable tests.
*/
public static void arrayToFile(int[] array, String outfile) {
try {
FileWriter fw = new FileWriter(outfile);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter outFile = new PrintWriter(bw);
for (int i : array) {
outFile.print(i + \" \");
}
outFile.close();
} catch (IOException e) {
System.err.println(\"Could not write to \" + outfile + \"\ \" + e);
}
}
/**
* Read ints from a file and return them in an int[]
*/
public static int[] arrayFromFile(String infile) throws FileNotFoundException,
InputMismatchException {
Scanner scan = new Scanner(new File(infile));
ArrayList aL = new ArrayList();
while (scan.hasNext()) {
aL.add(scan.nextInt());
}
scan.close();
int[] a = new int[aL.size()];
for (int i = 0; i < a.length; i++) {
a[i] = aL.get(i);
}
return a;
}
}
Order.java
public class Order {
/**
* Take an int[] and reorganize it so they are in ascending order.
*/
public static int order(int[] array) .
META-INF/MANIFEST.MF
Manifest-Version: 1.0
.classpath
PriorityQueue.classpublicsynchronizedclass PriorityQueue {
Heap q;
public void PriorityQueue(int, java.util.Comparator);
public Object peek();
public Object remove();
void add(Object);
boolean isEmpty();
public int size();
}
PriorityQueue.javaPriorityQueue.javaimport java.util.Comparator;
publicclassPriorityQueue<E>{
Heap q;
/**
*PriorityQueue initializes the queue.
*
* @param initialCapacity an int that is the heaps initial size.
* @param comparator the priority of various imputs.
*/
publicPriorityQueue(int initialCapacity,Comparator<?super E> comparator){
q=newHeap(initialCapacity,comparator);
}
/**
* Peek, returns the next item in the queue without removing it.
*
* If it is empty then null is returned.
* @return the next item in the queue.
*/
public E peek(){
if(q.size()==0){
returnnull;
}
return(E) q.findMax();
}
/**
* This removes the first item from the queue.
*
* It returns null if the queue is empty.
* @return the first item in the queue.
*/
public E remove(){
if(q.size()==0){
returnnull;
}
return(E) q.removeMax();
}
/**
* This adds item to the queue
* @param item that is added to the queue.
*/
void add(E item){
q.insert(item);
}
/**
* isEmpty returns if the queue is empty or not.
*
* @return boolean if the queue is empty or not.
*/
boolean isEmpty(){
if(q.size()!=0){
returnfalse;
}
returntrue;
}
/**
* size returns the size of the queue.
*
* @return int the size of the queue.
*/
publicint size(){
return q.size();
}
}
ArithmeticExpression.classpublicsynchronizedclass ArithmeticExpression {
BinaryTree t;
java.util.ArrayList list;
String equation;
void ArithmeticExpression(String) throws java.text.ParseException;
public String toString(BinaryTree);
public String toPostfixString(BinaryTree);
void setVariable(String, int) throws java.rmi.NotBoundException;
public int evaluate(BinaryTree);
}
ArithmeticExpression.javaArithmeticExpression.javaimport java.rmi.NotBoundException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Stack;
/**
* ArithmeticExpression takes equations in the form of strings creates a binary
* tree, and can return either the regular or postfix equation. It also allows
* them to be calculated.
*
*
* Extra Credit:
* ** it can handle spaces or no spaces in the string inputted. ** it can return
* regular or postfix notation
*
* @author tai-lanhirabayashi
*
*/
publicclassArithmeticExpression{
BinaryTree t;
ArrayList list;
String equation;
/**
* ArithmeticExpression is the construction which takes in a space
* delimitated equation containing "*,/,+,-" symbols and converts it into a
* binary tree.
*
* If the expression is not valid it will throw a ParseException. This is ...
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
Please help me to make a programming project I have to sue them today. Please help me make a
UnsortedList and SortedList classes. The instructor give me The code of the List and AbstracList
Classes that 2 pages we do not modify them. Do not modify this pages!!! List.java import
java.util.Iterator; /** * Represents List interface. * * @author Varik Hoang * @version Sep 26,
2016 * @param is of any object type. */ public interface List { /** * The method returns the
current number of elements in the list. * * @return the current number of elements in the list
greater than or equal 0 */ public int getSize(); /** * The method returns whether the list is empty.
* * @return true if list is empty, false otherwise. */ public boolean isEmpty(); /** * The method
returns whether value is in the list. * * @param value the value is assigned * @return true if
value in the list, false otherwise. */ public boolean contains(Type value); /** * The method
inserts an element into the list. * * @param value the value is assigned */ public void insert(Type
value); /** * The method clears the list. */ public void clear(); /** * The method returns a string
representation of list contents. * * @return a string representation of list contents. * @see
Object#toString() */ @Override public String toString(); /** * /** * The method removes first
element occurrence from the list. * * @param value the value is assigned * @return the removed
value */ public Type remove(Type value); /** * The method returns the index of value. * *
@param value the value is assigned. * @return the index of value if in the list, -1 otherwise. */
public int getIndex(Type value); /** * The method removes value at the given index. * *
@param index the index must be in range of 0 and size * @return the removed value * @throws
IndexOutOfBoundsException if index less than 0 or index greater than * or equal size */ public
Type removeAtIndex(int index); /** * The method replaces the value at the given index with the
given value. * * @param index the index must be in range of 0 and size * @param value the
value is assigned * @throws IndexOutOfBoundsException if index less 0 or index greater than
size */ public void set(int index, Type value); /** * Returns the value at the given index in the
list. * * @param index the index must be in range of 0 and size * @throws
IndexOutOfBoundsException if index less than 0 or greater size * @return the value at the given
index in the list. */ public Type get(int index); /** * The method returns an iterator for this list. *
* @return an iterator for the list. */ public Iterator iterator(); } Do not modify this pages public
abstract class AbstractList implements List { /** * The reference to the last element */ protected
ListNode tail; /** * The size of the list */ protected int size; /** * The constructor that initiate the
tail and size references */ public AbstractList() { tail = null; size = 0; } @Override public int
getSize() { return size; } @Override public bool.
I need help with this program for java.The program you are given t.pdffonecomp
I need help with this program for java.
The program you are given to start with: Lab4.java
The input file of ints:10,000ints.txt
The input file of words:172,822words.txt
Execute your program like this: C:\\> java Lab4 10000ints.txt 172822words.txt
Be sure to put the ints filename before the words filename. The starter file will be expecting them
in that order.
Lab#4\'s main method is completely written. Do not modify main. Just fill in the methods. Main
will load a large arrays of int, and then load a large array of Strings. As usual the read loops for
each file will be calling a resize method as needed. Once the arrays are loaded, each array will be
tested for the presence of duplicates via calls to indexOfFirstDuplicate(). Do not do any trim
operation.
Here are the rules:
In your methods that look for the first occurrence of a duplicate in each array, you must sort the
arrays before looking for the dupe. Do not search the array for the dupe until it is sorted. We
require this because an unsorted array would require a quadratic algorithm (N squared via nested
loops). If you sort you array first you will only incur an O(n*Log2n) cost for the sort with an
additional O(n) for the search. This is the best that can be done without using a technology such
as hashing which you will use for your next lab.
Inside your method to find the dupe you must sort the array first.
Do not define/use any new type or data structure that we have not covered yet.
Your traversal of the array looking for the dupe should require no more than one pass.
Be as efficient as you can without breaking rule #2.
Assuming the array below, the 1st occurrence of a duplicate is at index 4, not 3, since the
element at [4] is the first index position where that value was seen for a second time. Be sure you
understand this. Do not report the index of the first occurrence of a value as being the index
where the duplicate occurred.
Your job will be to fill in the definitions of these methods below main
static int[] upSizeArr( int[] fullArray ); // incoming array is FULL. It needs it\'s capacity doubled
static String[] upSizeArr( String[] fullArray ); // incoming array is FULL. It needs it\'s capacity
doubled
static int indexOfFirstDupe( int[] arr, int count ); // returns ind of 1st occurrence of duplicate
value
static int indexOfFirstDupe( String[] arr, int count ); // returns ind of 1st occurrence of duplicate
value
Here is the starting file!
Solution
HI, Please find my implementation of all required methods.
Please let me know in case of any issue.
/* Lab4.java Reads two files into two arrays then checks both arrays for dupes */
import java.io.*;
import java.util.*;
public class Lab4
{
static final int INITIAL_CAPACITY = 10;
static final int NOT_FOUND = -1; // indexOfFirstDupe returns this value if no dupes found
public static void main (String[] args) throws Exception
{
// ALWAYS TEST FIRST TO VERIFY USER PUT REQUIRED INPUT FILE NAME ON
THE COMMAND LINE
if (args.length < 1 )
{
Syst.
Please complete the assignment listed below.Define and explain, us.docxajoy21
Please complete the assignment listed below.
Define and explain, using at least five sentence or on-task bullet notes for each. Each answer earns up to five points. For each answer, please make five different substantive points, earning one point each.
Transnational corporation
Gentrification
Renewable resources
Desertification
Photochemical smog
Biodiversity
Barriers to migration
Hierarchical diffusion
Militant fundamentalism
Urbanization
Eastern European cities
Hazardous waste
The Endangered Species Act
Subsidence
Water Quality
Deforestation
Wetlands
Central place theory
Soil degradation
Hydraulic fracturing (fracking)
Wind power
Oil sands
Models of urban form
Hinterland
Agglomeration economies
.
Please cite sources for each question. Do not use the same sources f.docxajoy21
Please cite sources for each question. Do not use the same sources for each question. Minimum of 2 resources and 300 words.
Briefly contrast the views of Locke and Rousseau on how children develop.
a) What do ethologists, such as Lorenz, mean by imprinting on a parent-figure?
b) What observations led Bowlby to suggest that imprinting occurs in human infants? That is, what parallels between human infants and other species did he point to?
"For children to learn, we must praise their correct responses and correct their mistakes." Would Montessori agree? Explain.
What did Werner mean by "microgenesis" and "microgenetic mobility?" Give examples. Discuss some valuable aspects of these concepts.
Piaget's critics charge that he made development appear too slow. Discuss this criticism with respect to either: a) object permanence, b) conservation training, or c) Kamii's teaching methods. Then, describe the Piagetian approach.
Compare conventional and postconventional morality in Kohlberg's theory.
.
More Related Content
Similar to Write a program that will test a name) method no sorting routine from.docx
package singlylinkedlist; public class Node { public String valu.pdfamazing2001
package singlylinkedlist;
public class Node {
public String value;
public Node next;
public Node(String value) {
this.value = value;
}
@Override
public String toString() {
return value;
}
}
SingleyLinkedList.java :
package singlylinkedlist;
import java.io.*;
import java.util.*;
/**
* Defines the interface for a singly-linked list.
*
*/
public interface SinglyLinkedList {
/**
* @return Reference to the first node. If the list is empty, this method
* returns null.
*/
public Node getFirst();
/**
* @return Reference to the last node . If the list is empty, this method
* returns null.
*/
public Node getLast();
/**
* @return Number of nodes in the list
*/
public int size();
/**
* @return true if the list has no nodes; false otherwise
*/
public boolean isEmpty();
/**
* Removes all nodes in the list.
*/
public void clear();
/**
* Inserts a new node with the given value after cursor.
*
* @param cursor
* The node to insert after. Set this to null to insert value as
the
* new first Node.
* @param value
* The value to insert
* @return a reference to the newly inserted Node
*/
public Node insert(Node cursor, String value);
/**
* Inserts a new node with the given value at the "end" of the list.
*
* @param value
* @return a reference to the newly inserted Node
*/
public Node append(String value);
/**
* Removes the node after the specified Node (cursor) from the list.
*
* @param cursor
* A reference to the Node to remove.
*/
public void removeAfter(Node cursor);
/**
* Returns a reference to the first Node containing the key, starting from
the
* given Node.
*
* @param start
* @param key
* @return a reference to the first Node containing the key
*/
public Node find(Node start, String key);
/**
* Prints the values of all the items in a list
*/
public void printWholeList();
}
SinglyLinkedTester.java:
package sbccunittest;
import static java.lang.Math.*;
import static java.lang.System.*;
import static org.apache.commons.lang3.StringUtils.*;
import static org.junit.Assert.*;
import static sbcc.Core.*;
import java.io.*;
import java.lang.reflect.*;
import java.nio.file.*;
import java.util.*;
import java.util.stream.*;
import org.apache.commons.lang3.*;
import org.junit.*;
import org.w3c.dom.ranges.*;
import sbcc.*;
import singlylinkedlist.*;
/**
* 09/16/2021
*
* @author sstrenn
*
*/
public class SinglyLinkedListTester {
public static String newline = System.getProperty("line.separator");
public static int totalScore = 0;
public static int extraCredit = 0;
public static boolean isZeroScore = false;
public static String scorePreamble = "";
@BeforeClass
public static void beforeTesting() {
totalScore = 0;
extraCredit = 0;
}
@AfterClass
public static void afterTesting() {
if (isZeroScore) {
totalScore = 0;
extraCredit = 0;
}
println(scorePreamble + "Estimated score (w/o late penalties, etc.) is:
" + totalScore + " out of 25.");
// If the project follows the naming convention, save the results in a
folder on
// the desktop. (Alex Kohanim)
try {
String directory =
substri.
Java Programming- 1) Write a recursive method that finds and returns t.docxmichael1810
Java Programming:
1) Write a recursive method that finds and returns the sum of the elements in an int array. Also, write a program to test your method
** Please simple enough for a beginner to understand
Solution
/**
* @author
*
*/
public class RecusrsiveArraySum {
/**
* @param args
*/
public static void main(String[] args) {
int arr[] = { 3, 4, 6, 7 };
System.out
.println(\"Sum of array Elements: \" + sum(arr, arr.length - 1));
}
/**
* recursive sum of array elements
*
* @param array
* @param index
* @return
*/
public static int sum(int[] array, int index) {
// if array is empty
if (index < 0)
return 0;
if (index == 0) {
// when no index reaches first element
return array[0];
} else {
// adding array elements
return array[index] + sum(array, index - 1);
}
}
}
OUTPUT:
Sum of array Elements: 20
.
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
Create a menu-driven program that will accept a collection of non-negative integers from the
keyboard, calculate the mean and median values and display those values on the screen. Your
menu should have 6 options: 1. Add a number to the array 2. Display the mean 3. Display the
median 4. Print the array to the screen 5. Print the array in reverse order 6. Quit
Program particulars: Use an array of type int to store the integers entered by the user. There
must be error checking on the input integer. If it is negative, the program will print an error
message and re-prompt. This process will continue until a non-negative integer is entered. You
must use a try-catch structure to trap both types of input errors (like letters where numbers
should go) and range errors (like -1). You must write your own selectionSort utility method to
sort your array. Place the method in an external file named SortSearchUtil.java. There must be
error checking on the menu choice entered. If the user enters a choice not on the menu, the
program will print an error message, re-display the menu and re-prompt. This process will
continue until a valid option value is entered. Your solution must be modular. The design of your
methods is up to you, but the rules of “highly cohesive” and “loosely coupled” must be followed.
Your program should be well-documented. Explain what you’re doing in your code. Be sure to
include the usual name and assignment notes. Note your program will have to sort your array
before you can find the median. Include your SortSearchUtil.java file which will contain your
sort method.
This is what my project looks like already: Please fix it thanks. The SortSearchUtil will also be
included.
import java.util.Scanner;
public class ArraySorting
{
public static void main(String[] args)
{
int option;
int integer = 0;
int optionOne;
int optionTwo;
int optionThree;
int optionFour;
int optionFive;
int[] numbers = new int[5];
Scanner kb = new Scanner(System.in);
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
while((integer < 0))
{
System.out.println(\"I am sorry that is not a non-negative integer.\");
System.out.println(\"\");
System.out.println(\"Please enter a non-negative integer: \");
integer = kb.nextInt();
}
option = displayMenu(kb);
while (option != 6)
{
switch (option)
{
case 1:
optionOne(numbers);
System.out.println(\"\");
break;
case 2:
optionTwo(numbers);
System.out.println(\"\");
case 3:
//optionThree();
System.out.println(\"\");
break;
case 4:
//optionFour();
System.out.println(\"\");
break;
case 5:
//optionFive();
System.out.println(\"\");
break;
}
option = displayMenu(kb);
}
if (option == 6)
{
System.out.println();
System.out.println(\"Thank you. Have a nice day.\");
}
}
private static int displayMenu(Scanner kb)
{
int option = 0;
while (option != 1 && option != 2 && option != 3 && option != 4 && option !=5 && option
!=6)
{
System.out.println(\"\\t\\t1. Add a number to the array\ \\t\\t2. Display the mean\ \\t\.
week4_src/ArrayMethods.javaweek4_src/ArrayMethods.javapackage edu.drexel.ct290;
publicclassArrayMethods{
/**
* Pass and array to a method that will search through it for a given value.
*
* @param elementToFind: This is the item we want to find in the array.
* @param stringArray: This is the array to search through.
* @return Returns: The index of the element, or -1 if not found.
*/
publicint findElement(String elementToFind,String[] stringArray ){
int index =-1;
for(int i=0; i<stringArray.length; i++){
if( elementToFind.equals(stringArray[i])){
// If the element is found, set index
index = i;
}
}
return index;
}
/**
* Replace a value in an array.
*
* @param indexToReplace: The index where the new value should be written.
* @param newValue: The new value.
* @param stringArray: Change a value in this array.
* @return True if the given index is valid
*/
publicboolean replace(int indexToReplace,String newValue,String[] stringArray ){
boolean replaced =false;
// Use the if condition to make sure the given index is valid
if( indexToReplace >0&& indexToReplace < stringArray.length ){
stringArray[indexToReplace]= newValue;
replaced =true;
}
return replaced;
}
/**
* Insert a value into the array. From the insertion point on, the
* data needs to be copied down one space to make room for the new
* element indices .
*
* @param index: The index where the new element should be inserted
* @param element: The element to insert in the array
* @param array: The array to insert into
* @param indicesUsed: the number of elements in the array already used
* @return the array with the new value inserted
*/
publicString[] insert(int index,String element,String[] array,int indicesUsed){
// First, check that there is enough room in the array for
// another element. The parameter indicesUsed indicates how
// many elements of the array are already filled.
String[] newArray = array;
if( indicesUsed == array.length ){
newArray = makeBiggerArray(array);
}
// Now that we know there is enough room, move the
// elements down one spot in the array until we get to the
// insertion point. Make sure the element at the insertion
// point gets moved too.
int indexToMove = indicesUsed;
while( indexToMove >= index ){
newArray[indexToMove+1]= newArray[indexToMove];
indexToMove--;
}
// Set the given index to the new element
newArray[index]= element;
// Return the new array
return newArray;
}
/**
* Since arrays are fixed size, if you run out of room, the
* only options is to create a new bigger array, then copy
* the old data over.
* @param oldArray: The old data to copy into the new array
* @return The new bigger array
*/
publicString[] makeBiggerArray(String[] oldArray){
// Make the new array twice the size of the old one.
int newArraySize .
ReversePoem.java ---------------------------------- public cl.pdfravikapoorindia
ReversePoem.java :-
---------------------------------
public class ReversePoem {
/*This programs has you display a pessimistic poem from a list of phrases*/
// and then reverse the phrases to find another more optimistic poem.
public static void main(String[] args) throws Exception
{
//Queue object
MyQueue queue = new MyQueue<>();
//Stack object
MyStack stack = new MyStack<>();
//String buffer to apppend all Strings
StringBuffer sb = new StringBuffer();
// Create a single String object from the 16 Strings below
String set1 = \"I am part of a lost generation#and I refuse to believe that#\";
sb.append(set1);
String set2 = \"I can change the world#I realize this may be a shock but#\";
sb.append(set2);
String set3 = \"\'Happiness comes from within\'#is a lie, and#\";
sb.append(set3);
String set4 = \"\'Money will make me happy\'#So in 30 years I will tell my children#\";
sb.append(set4);
String set5 = \"they are not the most important thing in my life#\";
sb.append(set5);
String set6 = \"My employer will know that#I have my priorities straight because#\";
sb.append(set6);
String set7 = \"work#is more important than#family#I tell you this#\";
sb.append(set7);
String set8 = \"Once upon a time#Families stayed together#\";
sb.append(set8);
String set9 = \"but this will not be true in my era#\";
sb.append(set9);
String set10 = \"This is a quick fix society#Experts tell me#\";
sb.append(set10);
String set11 = \"30 years from now, I will be celebrating the 10th anniversary of my
divorce#\";
sb.append(set11);
String set12 = \"I do not concede that#I will live in a country of my own making#\";
sb.append(set12);
String set13 = \"In the future#Environmental destruction will be the norm#\";
sb.append(set13);
String set14 = \"No longer can it be said that#My peers and I care about this earth#\";
sb.append(set14);
String set15 = \"It will be evident that#My generation is apathetic and lethargic#\";
sb.append(set15);
String set16 = \"It is foolish to presume that#There is hope#\";
sb.append(set16);
String finalString = sb.toString();
String itmes[] = finalString.split(\"#\");
System.out.println(\"========== Original Phrase ==============\");
for(int i = 0 ; i < itmes.length;i++){
queue.enqueue(itmes[i]);
System.out.println(itmes[i]);
}
for(int i = 0 ; i < itmes.length;i++){
stack.push(queue.dequeue());
}
System.out.println(\"========== Reverse Phrase ==============\");
for(int i = 0 ; i < itmes.length;i++){
System.out.println(stack.pop());
}
/* You are given a list of phrases in Strings; the phrases
are separated by pound signs: \'#\':
1. Create a single String object from this list.
2. Then, split the String of phrases into an array of
phrases using the String split method.
3. Display a poem by walking through the array and
displaying each phrase one per line.
4. And, at the same time, place each phrase on a
MyQueue object using only the enqueue method.
5. After all the phrases have been placed on the queue,
transfer the phrases from the MyQueue object to a
MyS.
java I am trying to run my code but it is not letting me .pdfadinathassociates
java
I am trying to run my code but it is not letting me i dont know what i should do or fix. Thank you so
much for your help. This is the problem and my code will be on the bottom.
Problem #1 and Only
Dynamic Array of Integers Class
Create a class named DynamicArray that will have convenient functionality similar to JavaScripts
Array object and Javas ArrayList class. The class allows to store array of integers that can grow
and shrink as needed, search for values, remove elements, etc.
You are not allowed to use ArrayList object as well as any methods from java.util.Arrays
class.
Please see the list of required features and methods below.
private int array[] You MUST store the data internally in a regular partially-filled array of integers.
Please DO NOT USE ArrayList. The size of the allocated array is its capacity and will be
discussed below.
private int size. This variable stores the number of occupied elements in the array. Set to 0 in the
constructor.
Constructor with parameter. The parameter defines the capacity (length) of initial array. Allocates
array of given capacity (length), sets size field to 0. In case the parameter given to constructor is 0
or negative, IllegalArgumentException is being thrown.
No-argument constructor. Allocates array of length 3, assigns it to the array field, sets size field to
0.
Copy constructor. The constructor takes an object of type DynamicArray as a parameter and
copies it into the object it creates. The constructor throws IllegalArgumentException if the object
that was passed to copy from is null.
int getSize() returns the number of occupied elements in the array.
int getCapacity() returns the actual size (length) of the partially-filled array
int [] getArray() accessor returns the entire partially-filled array. Make sure you DO NOT return the
private array field, make a copy of it.
int [] toArray() accessor returns an occupied part of the partially-filled array. Make sure you DO
NOT return the private array field. Instead, allocate memory for the new array, copy the occupied
portion of the field into that new object, and return the new array.
public void push(int num) adds a new element to the end of the array and increments the size
field. If the array is full, you need to increase the capacity of the array:
Create a new array with the size equal to double the capacity of the original one.
Copy all the elements from the array field to the new array.
Add the new element to the end of the new array.
Use new array as an array field.
Make sure your method works well when new elements are added to an empty DynamicArray.
public int pop() throws RuntimeException removes the last element of the array and returns it.
Decrements the size field. If the array is empty a RuntimeException with the message Array is
empty must be thrown. At this point check the capacity of the array. If the capacity is 4 times larger
than the number of occupied elements (size), it is time to shrink the array:
Create a new array wi.
File LinkedList.java Defines a doubly-l.pdfConint29
File: LinkedList.java
/**
* Defines a doubly-linked list class
*/
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
/**
* Instantiates a new LinkedList with default values
* @postcondition
*/
public LinkedList() {
}
/**
* Converts the given array into a LinkedList
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
/**** ACCESSORS ****/
/**
* Returns the value stored in the first node
* @precondition
* @return the value stored at node first
* @throws NoSuchElementException
*/
public T getFirst() throws NoSuchElementException {
return null;
}
/**
* Returns the value stored in the last node
* @precondition
* @return the value stored in the node last
* @throws NoSuchElementException
*/
public T getLast() throws NoSuchElementException {
return null;
}
/**
* Returns the data stored in the iterator node
* @precondition
* @return the data stored in the iterator node
* @throw NullPointerException
*/
public T getIterator() throws NullPointerException {
return null;
}
/**
* Returns the current length of the LinkedList
* @return the length of the LinkedList from 0 to n
*/
public int getLength() {
return -1;
}
/**
* Returns whether the LinkedList is currently empty
* @return whether the LinkedList is empty
*/
public boolean isEmpty() {
return false;
}
/**
* Returns whether the iterator is offEnd, i.e. null
* @return whether the iterator is null
*/
public boolean offEnd() {
return false;
}
/**** MUTATORS ****/
/**
* Creates a new first element
* @param data the data to insert at the front of the LinkedList
* @postcondition
*/
public void addFirst(T data) {
return;
}
/**
* Creates a new last element
* @param data the data to insert at the end of the LinkedList
* @postcondition
*/
public void addLast(T data) {
return;
}
/**
* Inserts a new element after the iterator
* @param data the data to insert
* @precondition
* @throws NullPointerException
*/
public void addIterator(T data) throws NullPointerException{
return;
}
/**
* removes the element at the front of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeFirst() throws NoSuchElementException {
return;
}
/**
* removes the element at the end of the LinkedList
* @precondition
* @postcondition
* @throws NoSuchElementException
*/
public void removeLast() throws NoSuchElementException {
return;
}
/**
* removes the element referenced by the iterator
* @precondition
* @pos.
Please help solve this in C++ So the program is working fin.pdfankit11134
Please help solve this in C++. So the program is working fine but when submitting it, it gives me a
code -11, and I believe the problem is that after inserting the numbers it removes them one by one
until the last in the list, and when it tries to remove the last number in the list that is when it
counters the problem. Below is the full code but you just need to change something in the
SortedNumberList.h file under the bool remove function.
4.18 LAB: Sorted number list implementation with linked lists Step 1: Inspect the Node.h file
Inspect the class declaration for a doubly-linked list node in Node.h. Access Node.h by clicking on
the orange arrow next to main.cpp at the top of the coding window. The Node class has three
member variables: - a double data value, - a pointer to the next node, and - a pointer to the
previous node. Each member variable is protected. So code outside of the class must use the
provided getter and setter member functions to get or set a member variable. Node.h is read only,
since no changes are required. Step 2: Implement the Insert() member function A class for a
sorted, doubly-linked list is declared in SortedNumberList.h. Implement the SortedNumberList
class's Insert() member function. The function must create a new node with the parameter value,
then insert the node into the proper sorted position in the linked list. Ex: Suppose a
SortedNumberList's current list is 2347.2586, then Insert(33.5) is called. A new node with data
value 33.5 is created and inserted between 23 and 47.25, thus preserving the list's sorted order
and yielding: 2335.547.2586Step 3: Test in develop mode Code in main() takes a space-
separated list of numbers and inserts each into a SortedNumberList. The list is displayed after
each insertion. Ex: If input is 77154263.5 then output is: List after inserting 77 : 77 List after
inserting 15 : 1577 List after inserting -42 : -421577 List after inserting 63.5: -421563.577 Try
various program inputs, ensuring that each outputs a sorted list. Step 4: Implement the Remove()
member function Implement the SortedNumberList class's Remove(0 member function. The
function takes a parameter for the number to be removed from the list. If the number does not
exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the
number is removed from the list and true is returned. Uncomment the commented-out part in
main() that reads a second input line and removes numbers from the list. Test in develop mode to
ensure that insertion and removal both work properly, then submit code for grading. Ex: If input is
841972841961 then output is: List after inserting 84: 84 List after inserting 72 : 7284 List after
inserting 19: 1972 84 List after inserting 61: 1961 : 72 8 List after removing 19: 6172 84 List after
removing 84: 6172Current file: main.cpp - // Insert each value and show the sorted List's contents
after each insertion sortedNumberList list; for (auto term : terms) { doubl.
Step 1You need to run the JAVA programs in sections 3.3 and 3.5 for.pdfaloeplusint
Step 1:You need to run the JAVA programs in sections 3.3 and 3.5 for selection sort and
insertion sort. You need to attach the output results.
Step 2: You need to modify these two programs, save them, submit them, and add some
comments and explanations to them to sort the list elements from high to low value. The index
should be IndexHighest instead IndexSmallest.
Step3: Run the modified programs and print out the results and submit them.
In the end, you need the running results for original JAVA programs (selection and insertion sort
JAVA programs), the two modified programs to sort the values from high to low value for
selection and insertion sorts, and the results for the modified programs.
This program uses the selection sort algorithm to sort an array. The code has been modified to
also calculate how many item comparisons are done. You can try running the program with
different arrays to see how the total number of comparisons changes (or doesn't change).
CODE 3.3 ---
import java.util.Arrays;
public class SelectionSortDemo {
private static int selectionSort(int[] numbers) {
// A variable to hold the number of item comparisons
int comparisons = 0;
for (int i = 0; i < numbers.length - 1; i++) {
// Find index of smallest remaining element
int indexSmallest = i;
for (int j = i + 1; j < numbers.length; j++) {
comparisons++;
if (numbers[j] < numbers[indexSmallest]) {
indexSmallest = j;
}
}
// Swap numbers[i] and numbers[indexSmallest]
int temp = numbers[i];
numbers[i] = numbers[indexSmallest];
numbers[indexSmallest] = temp;
}
return comparisons;
}
public static void main(String[] args) {
// Create an array of numbers to sort
int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 };
// Display the contents of the array
System.out.println("UNSORTED: " + Arrays.toString(numbers));
// Call the selectionSort method
int comparisons = selectionSort(numbers);
// Display the sorted contents of the array
System.out.println("SORTED: " + Arrays.toString(numbers));
System.out.println("Total comparisons: " + comparisons);
}
}
CODE 3.5 ---
import java.util.Arrays;
public class InsertionSortDemo {
private static void insertionSort(int[] numbers) {
for (int i = 1; i < numbers.length; i++) {
int j = i;
while (j > 0 && numbers[j] < numbers[j - 1]) {
// Swap numbers[j] and numbers [j - 1]
int temp = numbers[j];
numbers[j] = numbers[j - 1];
numbers[j - 1] = temp;
j--;
}
}
}
public static void main(String[] args) {
// Create an array of numbers to sort
int[] numbers = { 10, 2, 78, 4, 45, 32, 7, 11 };
// Display the contents of the array
System.out.println("UNSORTED: " + Arrays.toString(numbers));
// Call the insertionSort method
insertionSort(numbers);
// Display the sorted contents of the array
System.out.println("SORTED: " + Arrays.toString(numbers));
}
}.
Everything needs to be according to the instructions- thank you! SUPPO.pdffirstchoiceajmer
Everything needs to be according to the instructions, thank you!
SUPPORTING CODE:
MyList.java
/**
This interface specifies the basic operations of any list-like object.
This interface contains a variation of the methods of the
standard java.util.List interface.
*/
public interface MyList {
/**
Adds an element at the end of the list.
*/
public void addToEnd(Object o);
/**
Inserts an element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void insertAt(int index, Object o);
/**
Removes the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public void removeAt(int index);
/**
Returns the element at the specified index
Throws NoSuchElementException if index is out of bounds.
*/
public Object getAt(int index);
/**
Returns the size of the list.
@return the number of elements in the list
*/
public int getSize();
/**
Returns a list iterator for this list.
@return a list iterator for this list
*/
public MyListIterator getIterator();
}
MyListIterator.java
/**
A list iterator allows access of a position in a list.
This interface contains a subset of the methods of the
standard java.util.ListIterator interface. The methods for
backward traversal are not included.
*/
public interface MyListIterator
{
/**
Moves the iterator past the next element.
@return the traversed element
*/
Object next();
/**
Tests if there is an element after the iterator
position.
@return true if there is an element after the iterator
position
*/
boolean hasNext();
}
Main.java
// you may use this file to write and run code to test your MyArrayList class
public class Main {
public static void main(String[] args) {
}
}
FILE THAT NEEDS THAT NEEDS CODE:
MyArrayList.java
// Complete the implementation of your MyArrayList class in this file
public class MyArrayList implements MyList {
// Implement the required fields and methods here
private int capacity = 8;
private Object[ ] array = new Object [capacity];
private int size = 0;
@Override
public void add(Object o) {
if (size >= capacity){
Object[] temp = new Object[2*array.length];
for(int i=0;i<size;++i){
temp[i] = array[i];
}
this.capacity = 2*array.length;
array = temp;
array[size++] = o;
return;
}
else
{
array[size++] = o;
}
}
@Override
public int size() {
return size;
}
@Override
public Object at(int index) {
if (index >= capacity)
return null;
else
return array[index];
}
@Override
public void insertAt(int index, Object o) {
if (index >= capacity)
return;
else
{
size++;
for (int x = size - 1; x > index; x--) {
array[x] = array[x - 1];
}
array[index] = o;
}
}
@Override
public void removeAt(int index) {
if (index >= size || size == 0)
return;
else {
Object e = array[index];
for (int x = index; x < this.array.length - 1; x++) {
array[x] = array[x + 1];
}
size--;
}
}
public void ensureCapacity(int minCapacity) {
}
public void trimToSize() {
ensureCapacity(size);
}
// Do not alter the code below
@Override
public MyListIterator getIterator() {
return new MyA.
Labprogram.java
LinkedList.java
import java.util.NoSuchElementException;
public class LinkedList {
private class Node {
private T data;
private Node next;
private Node prev;
public Node(T data) {
this.data = data;
this.next = null;
this.prev = null;
}
}
private int length;
private Node first;
private Node last;
private Node iterator;
/**** CONSTRUCTORS ****/
public LinkedList() {
first = null;
last = null;
iterator = null;
length = 0;
}
/**
* Converts the given array into a LinkedList
*
* @param array the array of values to insert into this LinkedList
* @postcondition
*/
public LinkedList(T[] array) {
}
/**
* Instantiates a new LinkedList by copying another List
*
* @param original the LinkedList to copy
* @postcondition a new List object, which is an identical,
* but separate, copy of the LinkedList original
*/
public LinkedList(LinkedList original) {
}
public T getFirst() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
return first.data;
}
public T getLast() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
return last.data;
}
public T getIterator() throws NullPointerException {
if (iterator != null) {
return iterator.data;
} else {
throw new NullPointerException("Iterator is off the end opf the list.");
}
}
public int getLength() {
return length;
}
public boolean isEmpty() {
return length == 0;
}
public boolean offEnd() {
return iterator == null;
}
public void addFirst(T data) {
Node newNode = new Node(data);
if (isEmpty()) {
first = newNode;
last = newNode;
} else {
newNode.next = first;
first.prev = newNode;
first = newNode;
}
length++;
}
public void addLast(T data) {
Node newNode = new Node(data);
if (isEmpty()) {
first = newNode;
last = newNode;
} else {
last.next = newNode;
newNode.prev = last;
last = newNode;
}
length++;
}
public void addIterator(T data) throws NullPointerException {
if (offEnd()) {
throw new NullPointerException("addIterator Iterator is off end.");
}
if (iterator == last) {
addLast(data);
} else {
Node newNode = new Node(data);
Node next = iterator.next;
newNode.next = next;
newNode.prev = iterator;
iterator.next = newNode;
next.prev = newNode;
length++;
}
}
public void removeFirst() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
if (length == 1) {
first = null;
last = null;
iterator = null;
} else {
if (iterator == first) {
iterator = null;
}
first = first.next;
first.prev = null;
}
length--;
}
public void removeLast() throws NoSuchElementException {
if (isEmpty()) {
throw new NoSuchElementException("The list is empty");
}
if (length == 1) {
first = null;
last = null;
iterator = null;
} else {
if (iterator == last) {
iterator = null;
}
last = last.prev;
last.next = null;
}
length--;
}
public void removeIterator() throws NullPointerException {
if (offEnd()) {
throw new NullPointerException("Iterator is off the end opf the list.");
}
if (iterator .
MinOfFourNumbers.javaimport java.util.Scanner;public class MinOf.pdfaptex1
If I assume you meant supply is determined as [q_(s)=3p^2-4p] and demand is determined as
[q_(d)=-p^2+24] then I would calculate that the equilibrium is where [q_(s)=q_(d)] and p>0. So I
set up the equation [3p^2-4p=-p^2+24] I add [p^2] to both sides of the equation yielding [4p^2-
4p=24] I subtract 24 from each side, yielding the quadratic equation [4p^2-4p-24=0] I factor the
equation [(2p-6)(2p+4)=0] so that means [2p-6=0] or [2p+4=0] In the former case 2p=6 so p=3,
and in the latter 2p=-4 so p=-2. The economic nature of the question requires p>0, so [p!=-2] and
thus the equilibrium price is $3.00 each. Then to determine the equilibrium quantity, we solve
either q expression for p=3.
[q_(s)=3(3)^2-4(3)=3(9)-12=27-12=15]
[q_(d)=-(3^2)+24=-9+24=15]
So the equilibrium quantity is 15 items.
The price and quantity for market equilibrium is 15 items at $3.00 each.
Solution
If I assume you meant supply is determined as [q_(s)=3p^2-4p] and demand is determined as
[q_(d)=-p^2+24] then I would calculate that the equilibrium is where [q_(s)=q_(d)] and p>0. So I
set up the equation [3p^2-4p=-p^2+24] I add [p^2] to both sides of the equation yielding [4p^2-
4p=24] I subtract 24 from each side, yielding the quadratic equation [4p^2-4p-24=0] I factor the
equation [(2p-6)(2p+4)=0] so that means [2p-6=0] or [2p+4=0] In the former case 2p=6 so p=3,
and in the latter 2p=-4 so p=-2. The economic nature of the question requires p>0, so [p!=-2] and
thus the equilibrium price is $3.00 each. Then to determine the equilibrium quantity, we solve
either q expression for p=3.
[q_(s)=3(3)^2-4(3)=3(9)-12=27-12=15]
[q_(d)=-(3^2)+24=-9+24=15]
So the equilibrium quantity is 15 items.
The price and quantity for market equilibrium is 15 items at $3.00 each..
OrderTest.javapublic class OrderTest { Get an arra.pdfakkhan101
OrderTest.java
public class OrderTest {
/**
* Get an array of specified size and pass it to Order.order().
* Report the results.
*/
public static void main(String[] args) {
if (args.length != 1) {//1
System.out.println(\"Usage: java OrderTest sizeOfArray\ \"
+ \"\\tor\ \\tjava OrderTest arrayFile\");
System.exit(1);
}
// create or read the int[]
int size = 0;
int[] array = new int[0];//5
try {
size = Integer.parseInt(args[0]);
array = ArrayOfInts.randomizedArray(size);
} catch (NumberFormatException nfe) {//8
try {
array = ArrayOfInts.arrayFromFile(args[0]);
size = array.length;
} catch (Exception e) {
System.err.println(\"unable to read array from \" + args[0]);
System.exit(1);//14
}
}
System.out.println(\"before:\");//15
for (int i = 0; i < array.length; i++) {//2 n
System.out.printf(((i+1) % 10 > 0) ? \" %d\" : \" %d\ \", array[i]);//1
}
int myNum = Order.order(array); //this is the call we want to measure
System.out.println(\"\ after:\");//18
for (int i = 0; i < array.length; i++) {//2 n
System.out.printf(((i+1) % 10 > 0) ? \" %d\" : \" %d\ \", array[i]);
}
System.out.println(myNum);
}
}
ArrayOfInts.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.Scanner;
public class ArrayOfInts {
/**
* Returns an array of consecutive ints from 1 to size.
*/
public static int[] orderedArray(int size) {
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = i+1;
}
return a;
}
/**
* Returns a randomized array containing ints from 1 to size.
*/
public static int[] randomizedArray(int size) {
ArrayList aL = new ArrayList();
for (int i = 0; i < size; i++) {
aL.add(i+1);
}
Collections.shuffle(aL);
int[] a = new int[size];
for (int i = 0; i < size; i++) {
a[i] = aL.get(i);
}
return a;
}
/**
* Writes an int[] to a plain-text file with ints separated by spaces.
* Useful for creating input files for repeatable tests.
*/
public static void arrayToFile(int[] array, String outfile) {
try {
FileWriter fw = new FileWriter(outfile);
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter outFile = new PrintWriter(bw);
for (int i : array) {
outFile.print(i + \" \");
}
outFile.close();
} catch (IOException e) {
System.err.println(\"Could not write to \" + outfile + \"\ \" + e);
}
}
/**
* Read ints from a file and return them in an int[]
*/
public static int[] arrayFromFile(String infile) throws FileNotFoundException,
InputMismatchException {
Scanner scan = new Scanner(new File(infile));
ArrayList aL = new ArrayList();
while (scan.hasNext()) {
aL.add(scan.nextInt());
}
scan.close();
int[] a = new int[aL.size()];
for (int i = 0; i < a.length; i++) {
a[i] = aL.get(i);
}
return a;
}
}
Order.java
public class Order {
/**
* Take an int[] and reorganize it so they are in ascending order.
*/
public static int order(int[] array) .
META-INF/MANIFEST.MF
Manifest-Version: 1.0
.classpath
PriorityQueue.classpublicsynchronizedclass PriorityQueue {
Heap q;
public void PriorityQueue(int, java.util.Comparator);
public Object peek();
public Object remove();
void add(Object);
boolean isEmpty();
public int size();
}
PriorityQueue.javaPriorityQueue.javaimport java.util.Comparator;
publicclassPriorityQueue<E>{
Heap q;
/**
*PriorityQueue initializes the queue.
*
* @param initialCapacity an int that is the heaps initial size.
* @param comparator the priority of various imputs.
*/
publicPriorityQueue(int initialCapacity,Comparator<?super E> comparator){
q=newHeap(initialCapacity,comparator);
}
/**
* Peek, returns the next item in the queue without removing it.
*
* If it is empty then null is returned.
* @return the next item in the queue.
*/
public E peek(){
if(q.size()==0){
returnnull;
}
return(E) q.findMax();
}
/**
* This removes the first item from the queue.
*
* It returns null if the queue is empty.
* @return the first item in the queue.
*/
public E remove(){
if(q.size()==0){
returnnull;
}
return(E) q.removeMax();
}
/**
* This adds item to the queue
* @param item that is added to the queue.
*/
void add(E item){
q.insert(item);
}
/**
* isEmpty returns if the queue is empty or not.
*
* @return boolean if the queue is empty or not.
*/
boolean isEmpty(){
if(q.size()!=0){
returnfalse;
}
returntrue;
}
/**
* size returns the size of the queue.
*
* @return int the size of the queue.
*/
publicint size(){
return q.size();
}
}
ArithmeticExpression.classpublicsynchronizedclass ArithmeticExpression {
BinaryTree t;
java.util.ArrayList list;
String equation;
void ArithmeticExpression(String) throws java.text.ParseException;
public String toString(BinaryTree);
public String toPostfixString(BinaryTree);
void setVariable(String, int) throws java.rmi.NotBoundException;
public int evaluate(BinaryTree);
}
ArithmeticExpression.javaArithmeticExpression.javaimport java.rmi.NotBoundException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Stack;
/**
* ArithmeticExpression takes equations in the form of strings creates a binary
* tree, and can return either the regular or postfix equation. It also allows
* them to be calculated.
*
*
* Extra Credit:
* ** it can handle spaces or no spaces in the string inputted. ** it can return
* regular or postfix notation
*
* @author tai-lanhirabayashi
*
*/
publicclassArithmeticExpression{
BinaryTree t;
ArrayList list;
String equation;
/**
* ArithmeticExpression is the construction which takes in a space
* delimitated equation containing "*,/,+,-" symbols and converts it into a
* binary tree.
*
* If the expression is not valid it will throw a ParseException. This is ...
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
Please help me to make a programming project I have to sue them today. Please help me make a
UnsortedList and SortedList classes. The instructor give me The code of the List and AbstracList
Classes that 2 pages we do not modify them. Do not modify this pages!!! List.java import
java.util.Iterator; /** * Represents List interface. * * @author Varik Hoang * @version Sep 26,
2016 * @param is of any object type. */ public interface List { /** * The method returns the
current number of elements in the list. * * @return the current number of elements in the list
greater than or equal 0 */ public int getSize(); /** * The method returns whether the list is empty.
* * @return true if list is empty, false otherwise. */ public boolean isEmpty(); /** * The method
returns whether value is in the list. * * @param value the value is assigned * @return true if
value in the list, false otherwise. */ public boolean contains(Type value); /** * The method
inserts an element into the list. * * @param value the value is assigned */ public void insert(Type
value); /** * The method clears the list. */ public void clear(); /** * The method returns a string
representation of list contents. * * @return a string representation of list contents. * @see
Object#toString() */ @Override public String toString(); /** * /** * The method removes first
element occurrence from the list. * * @param value the value is assigned * @return the removed
value */ public Type remove(Type value); /** * The method returns the index of value. * *
@param value the value is assigned. * @return the index of value if in the list, -1 otherwise. */
public int getIndex(Type value); /** * The method removes value at the given index. * *
@param index the index must be in range of 0 and size * @return the removed value * @throws
IndexOutOfBoundsException if index less than 0 or index greater than * or equal size */ public
Type removeAtIndex(int index); /** * The method replaces the value at the given index with the
given value. * * @param index the index must be in range of 0 and size * @param value the
value is assigned * @throws IndexOutOfBoundsException if index less 0 or index greater than
size */ public void set(int index, Type value); /** * Returns the value at the given index in the
list. * * @param index the index must be in range of 0 and size * @throws
IndexOutOfBoundsException if index less than 0 or greater size * @return the value at the given
index in the list. */ public Type get(int index); /** * The method returns an iterator for this list. *
* @return an iterator for the list. */ public Iterator iterator(); } Do not modify this pages public
abstract class AbstractList implements List { /** * The reference to the last element */ protected
ListNode tail; /** * The size of the list */ protected int size; /** * The constructor that initiate the
tail and size references */ public AbstractList() { tail = null; size = 0; } @Override public int
getSize() { return size; } @Override public bool.
I need help with this program for java.The program you are given t.pdffonecomp
I need help with this program for java.
The program you are given to start with: Lab4.java
The input file of ints:10,000ints.txt
The input file of words:172,822words.txt
Execute your program like this: C:\\> java Lab4 10000ints.txt 172822words.txt
Be sure to put the ints filename before the words filename. The starter file will be expecting them
in that order.
Lab#4\'s main method is completely written. Do not modify main. Just fill in the methods. Main
will load a large arrays of int, and then load a large array of Strings. As usual the read loops for
each file will be calling a resize method as needed. Once the arrays are loaded, each array will be
tested for the presence of duplicates via calls to indexOfFirstDuplicate(). Do not do any trim
operation.
Here are the rules:
In your methods that look for the first occurrence of a duplicate in each array, you must sort the
arrays before looking for the dupe. Do not search the array for the dupe until it is sorted. We
require this because an unsorted array would require a quadratic algorithm (N squared via nested
loops). If you sort you array first you will only incur an O(n*Log2n) cost for the sort with an
additional O(n) for the search. This is the best that can be done without using a technology such
as hashing which you will use for your next lab.
Inside your method to find the dupe you must sort the array first.
Do not define/use any new type or data structure that we have not covered yet.
Your traversal of the array looking for the dupe should require no more than one pass.
Be as efficient as you can without breaking rule #2.
Assuming the array below, the 1st occurrence of a duplicate is at index 4, not 3, since the
element at [4] is the first index position where that value was seen for a second time. Be sure you
understand this. Do not report the index of the first occurrence of a value as being the index
where the duplicate occurred.
Your job will be to fill in the definitions of these methods below main
static int[] upSizeArr( int[] fullArray ); // incoming array is FULL. It needs it\'s capacity doubled
static String[] upSizeArr( String[] fullArray ); // incoming array is FULL. It needs it\'s capacity
doubled
static int indexOfFirstDupe( int[] arr, int count ); // returns ind of 1st occurrence of duplicate
value
static int indexOfFirstDupe( String[] arr, int count ); // returns ind of 1st occurrence of duplicate
value
Here is the starting file!
Solution
HI, Please find my implementation of all required methods.
Please let me know in case of any issue.
/* Lab4.java Reads two files into two arrays then checks both arrays for dupes */
import java.io.*;
import java.util.*;
public class Lab4
{
static final int INITIAL_CAPACITY = 10;
static final int NOT_FOUND = -1; // indexOfFirstDupe returns this value if no dupes found
public static void main (String[] args) throws Exception
{
// ALWAYS TEST FIRST TO VERIFY USER PUT REQUIRED INPUT FILE NAME ON
THE COMMAND LINE
if (args.length < 1 )
{
Syst.
Similar to Write a program that will test a name) method no sorting routine from.docx (20)
Please complete the assignment listed below.Define and explain, us.docxajoy21
Please complete the assignment listed below.
Define and explain, using at least five sentence or on-task bullet notes for each. Each answer earns up to five points. For each answer, please make five different substantive points, earning one point each.
Transnational corporation
Gentrification
Renewable resources
Desertification
Photochemical smog
Biodiversity
Barriers to migration
Hierarchical diffusion
Militant fundamentalism
Urbanization
Eastern European cities
Hazardous waste
The Endangered Species Act
Subsidence
Water Quality
Deforestation
Wetlands
Central place theory
Soil degradation
Hydraulic fracturing (fracking)
Wind power
Oil sands
Models of urban form
Hinterland
Agglomeration economies
.
Please cite sources for each question. Do not use the same sources f.docxajoy21
Please cite sources for each question. Do not use the same sources for each question. Minimum of 2 resources and 300 words.
Briefly contrast the views of Locke and Rousseau on how children develop.
a) What do ethologists, such as Lorenz, mean by imprinting on a parent-figure?
b) What observations led Bowlby to suggest that imprinting occurs in human infants? That is, what parallels between human infants and other species did he point to?
"For children to learn, we must praise their correct responses and correct their mistakes." Would Montessori agree? Explain.
What did Werner mean by "microgenesis" and "microgenetic mobility?" Give examples. Discuss some valuable aspects of these concepts.
Piaget's critics charge that he made development appear too slow. Discuss this criticism with respect to either: a) object permanence, b) conservation training, or c) Kamii's teaching methods. Then, describe the Piagetian approach.
Compare conventional and postconventional morality in Kohlberg's theory.
.
Please choose one of the following questions to answer for this week.docxajoy21
Please choose one of the following questions to answer for this week's assignment. When you respond to your fellow classmates this week, please choose someone who answered a different question than your own. This will help you familiarize yourself with more of the material. Remember, you need to post at least three responses to receive full credit for this assignment.
1. The French revolutionaries claimed that they were inspired by the Enlightenment
philosophes
. Would the
philosophes
we studied back in Week 2 have approved of how the Revolution started? What about how it developed through the 1790s?
2. In his
Reflections on the Revolutions in France,
British member of Parliament Edmund Burke predicted the Terror. Was this a lucky guess on his part or were the seeds of of the Terror part of the Revolution from the beginning? Why?
3. The French Revolution had a profound impact on the world, not just within the borders of France. Why were some nations willing to accept its gains-at least, partially-while others resisted them? Which country do you think was the most unwilling to accept the new ideas of
liberte,
e
galite,
and
fraternite
? Other than France, which was most willing to embrace the Revolutionary ideals? Why?
4. Although no historian doubts the importance of the reign of Napoleon in European (and even world) history, they do argue over the interpretation of these events. For example, they are torn on the role Napoleon played in the Revolution. Some argue that he continued the spirit of the Revolution, despite creating an Empire. Others believe he murdered it. Some include Napoleon's reign as a stage of the actual Revolution, while others consider it its own separate event. What do you think? Do you think Napoleon continued and spread the Revolution? Or do you think he destroyed its ideals when creating his empire? Do you think his reign should qualify as a separate historical event from the Revolution? Or was it simply another stage in a long process?
.
Please check the attachment for my paper.Please add citations to a.docxajoy21
Please check the attachment for my paper.
Please add citations to all paragraphs.
Also, please check the paper for plagiarism and please add two more pages on (Social Media & In person Communication) to make it fit the essay so far.
And please use 5 more sources in the paper. (1 Article, 1 Book, 1 Encyclopedia, 1 Newspaper and 1 magazine).
Finally, please correct all the grammar mistakes in the first 3 pages.
And please get rid of the first person used. (I,we etc...)
.
Please answer to this discussion post. No less than 150 words. Refer.docxajoy21
Please answer to this discussion post. No less than 150 words. Reference and APA style needed. Please no plagiarism. Similarity is <20%. Thanks
The most interesting thing about this chapter is that it helps people and scholars to develop skills to influence strategy in nowadays changing healthcare environment. The topic also contributes an extensive range of themes in strategies and politics, offering more complete contextual that can be in other policies textbook in the market (Mason, Leavitt, & Chaffee, 2013). The topics also entail up-to-date updates concerning conflict organization, health economics, politicization, use of media as well as working with societies for change. Reviewed copy take account of new supplement with coverage of advanced reasonably priced care act. According to this perceptions and strategies, every individual will be equipped and ready to play a leadership role under four spheres where nurses are governmentally efficient, the workstation, government, specialized organization as well as the community (American Nurses Association, 2010). The topic has helped me to know more of nursing and healthcare policies and politics.
In thus, have understood that the concept of nursing policies influences can be defined as a nursing ability to have active, effective on decision making as well as affairs connected to health care by use of power, support, and strategy capability, and establishing or strengthening images. The nursing policy and politics within a healthcare connect to my clinical practices because as a nurse, I should view myself as a professional with the ability and being responsible for influencing recent and forthcoming health care conveyance system. But to attain this, there must be the presence of policies that define and assimilate suitable standards for healthcare delivery as well as addressing essential conditions for that care to happen.
References
American Nurses Association. (2010).
Nursing's social policy statement: The essence of the profession
. Nursesbooks. org.
Mason, D. J., Leavitt, J. K., & Chaffee, M. W. (2013).
Policy and Politics in Nursing and Healthcare-Revised Reprint
. Elsevier Health Sciences.
.
Please attach Non-nursing theorist summaries.
Jigsaw/Executive Summary Grading Criteria
Albert Bandura: Self-Efficacy
Points Possible
Your Points
Summary Paper
Introduction/Conclusion
2
History/Origins of Theory
3
Major Precepts of Theory
Current Application(s) of Theory
Mechanics
Grammar/form/spelling/punctuation/ Logical flow/readability/APA format
3
Citations and references
2
Total Points
10
.
Please answer the question .There is no work count. PLEASE NUMBER .docxajoy21
Please answer the question .There is no work count. PLEASE NUMBER THE ANSWERS.
1-How does the value of individual freedom effect the ethics of our American society differently than the value of family and religious loyalty?
What are some other values of contemporary American society?
How are they in conflict with the values of the 1950's?
Is one set of values superior to another?
Why?
2-Islam means, at its root, surrender.
How does Islamic belief and practice reflect the importance of surrendering to Allah?
3-What do you think about this focus on prayer?
What is the standard of prayer in Judaism?
What about in Christianity?
What about in your own life?
Are you humbled and challenged by the knowledge that Muslims stop 5 times to pray?
4-Do you think the call to prayer is a call to obedience or a reminder for devotion?
5-Please answer this question and discuss the implications, probe for assumptions, draw out evidence and clarify perspectives.
What was the influence of Islam on the arts and sciences in its Golden Age, which is when Europe was experiencing the Medieval Period, sometimes called the Dark Ages?
6a- You mention the art form of mosaic (you called it "geometric pieces") and I want to draw the class' attention to the idea of unity in diversity within this art form.
First, the main theological point of Islam is that Allah is one.
As the Muslim scientists and artists searched to make discoveries in their given fields of study, they were constantly looking for the unity of Allah in the diversity of the creation.
The artist brought out that unity in mosaic and in textiles.
The mosaic is a pattern that is derived by putting thousands of small colored stones together to make one design.
The individual pieces of stone lose their importance within the whole, but without each piece the whole would not be complete.
So their concept of God came through in their art.
6b-How else did the Muslims bring out unity in diversity?
7a-Because they were prohibited from figures in art, the Muslims developed other art forms and calligraphy is one of those art forms.
They believed that the words of the Qur'an were beautiful (to hear and for life) so they started to write them in a beautiful way and thus calligraphy developed.
Art is one of those things that cannot be totally squelched.
If you contain an artist in one area, their emotion will burst forth in another area.
7b What do you think about the Muslims' use of calligraphy?
The Muslim religion started very rapidly.
8--Class, Based on the information about Muhammad and the early spread of Islam, what do you think was the most important factor in the amazing way that Islam grew so quickly?
.
Please answer the following questions. Please cite your references..docxajoy21
Please answer the following questions. Please cite your references.
According to Section I readings, Democracy: what it is and what it is not? (15 points) (See attached PDF)
Is the U.S. a democratic country? Has your view/opinion changed or unchanged now comparing to your answer at the beginning of the class? (15 points)
What does democracy mean to you personally? What will you do/participate/take action to ensure/protect your definition of democracy? (15 points)
Has the United States been a positive or negative influence on global democracy? (15 points)
Identify yourself as either a municipal, state or federal lawmaker, discuss your action/plan for democracy in the United States and her role as it pertains to the spread of democracy and democratic values throughout the world in the 21
st
Century. (40 points)
.
Please answer the following questions.1. 1. Are you or.docxajoy21
Please answer the following questions.
1.
1.
Are you or your immediate supervisor involved with staffing decisions?
If so, describe how staffing forecasts are prepared.
2.
2.
Does your organization use a flexible or a static budget?
Explain and provide examples.
Note: I work at a hospital as a psychiatric technician
.
Please answer the following question with 200-300 words.Q. Discu.docxajoy21
Please answer the following question with 200-300 words.
Q. Discuss why Hurston's assertions in "Characteristics of Negro Expression" would have been frowned upon by middle and upper class blacks.
Source:
Zora Neale Hurston -
"Characteristics of Negro Expression"
Please don't forget to include at least one quote from the passage.
.
Please answer the following question Why do you think the US ha.docxajoy21
Please answer the following question:
Why do you think the US has such a high homicide rate compared to other Western countries? What would you do to change that?
The paper needs to be 3-4 pages long, 12 point font, Times New Roman, and double spaced. The paper needs to be in
APA format. All sources must be cited.
Due on April 7, 2017 @ 12:30pm.
Anything after 12:30pm will not be accepted.
.
Please answer the following questions. Define tunneling in the V.docxajoy21
Please answer the following questions.
Define tunneling in the VPN environment and explain the difference between voluntary and compulsory tunnels.
How does the VPN technology provides security to a corporate network? You may also choose to compare two or more VPN technologies.
Consider the VPN technologies studied in this session, including IPSec in the Tunnel mode, L2TP over IPsec, PPTP and SSL/TLS VPN. Which one would you choose for your company? Can you discuss its advantages and its weakness or drawbacks? Do you know some products that are based on that technology?
Discuss the specific techniques for securing the remote client and the remote access server and the common concerns of each.
.
Please answer the following questions1. How can you stimulate the.docxajoy21
Please answer the following questions:
1. How can you stimulate the brain development of an infant?
2. How do parents cope with the growing autonomy of toddlers and what should be done about temper tantrums?
3. How do children in these stages of development change the life style of their parents?
Observation:
Have a conversation with the parent of a toddler. What are the differences of dealing with an infant and a toddler?
.
Please answer the following questions very deeply and presicely .docxajoy21
Please answer the following questions very deeply and presicely :
"Ziff"
!)
As Ziff define artwork, what do you think would consider as an artwork, and who do you think is capable of deciding if the work is art or not?
"Danto"
2) Why do you think Danto compares Socrates and Hamlet in the beginning? Do you feel as if it was an imitation of nature? How would you describe the word "art" with these two philosophers?
* The answer should be (4-8 sentences)
.
Please answer the following questions in an informal 1 ½ - 2-page es.docxajoy21
Please answer the following questions in an informal 1 ½ - 2-page essay:
Describe Hubert’s characterization of white society in New York City during the Harlem Renaissance.
What does this essay reveal about black culture in Harlem?
Why does Hubert describe the Harlem Renaissance as “the golden age for Negro writers, artists, and musicians?”
Black writer Alain Locke used the term “New Negro” to describe individuals such as Hubert. What did that mean?
Please conclude your essay with at least one question for discussion. Choose a question that you think will both enlighten and enliven your discussion section.
.
Please answer the following questions in a response of 150 to 200 wo.docxajoy21
Please answer the following questions in a response of 150 to 200 words each, and submit your responses in a Word attachment no later than Sunday of this week at 11:59 p.m. EST.
Discuss the reasons for the Iranian hostage crisis in 1979, and how that has impacted US-Iranian relations since.
Examine the motives of both the United States and the Soviet Union during the Cold War. Provide at least two examples in which these motives led to potential conflict between the two superpowers and/or their proxies (smaller nations in their respective spheres of influence).
Evaluate the assumption that the East European revolutions of 1989-90 that led to the breakup of the Warsaw Pact were a direct cause for the collapse of the Soviet Union. To what extent did these events influence the latter? Could the USSR have relinquished control of Eastern Europe yet remained intact?
.
Please answer these questions regarding the (TILA) Truth in Lending .docxajoy21
Please answer these questions regarding the (TILA) Truth in Lending Act.
1-Did the legislation or regulation solve the problem(s)? How?
2-Who were the major stakeholders?
The answers need to be complete, through and supported by evidence.
The length should as much as needed to answer the questions but not less than three quarters of a page for each question.
.
Please answer the following question pertaining to psychology. Inc.docxajoy21
Please answer the following question pertaining to psychology.
Include references/cites
at least 175 words each question.
1. 12
Despite much effort, a definition of personality has been elusive. Why do you think this is the case? How does this influence the relationship between personality theory and personality assessment?
13
What are the differences in test construction between the Minnesota Multiphasic Personality Inventory (MMPI) and the NEO Personality Inventory? Which do you think is more valid? Explain your responses.
16
How are assessments used in the workplace? How can assessments be misused in the workplace?
Analyze the relationship between the major theories of personality and assessments of personality.
Evaluate the strengths and weaknesses of personality assessment methods.
Describe the application of psychological assessments in the workplace.
.
Please answer the following questions in a response of 250 to 300 .docxajoy21
Please answer the following questions in a response of
250 to 300 words each
, and submit your responses in a Word attachment no later than Sunday of this week at 11:59 p.m. EST.
Identify the causes, key battles, and outcome of World War II in both Europe and the Pacific.
Identify the causes of the Cold War, and explain whether you think the Cold War was inevitable or not following World War II. How did the conflict between communist and non-communist powers manifest in China and Korea?
Pollard, E., Rosenberg, C., & Tignor, R. (2015). Worlds Together Worlds Apart. From 1000 CE to the Present (1st ed., Vol. 2). New York, NY: W.W. Norton & Company.
.
Please answer the three questions completly. I have attached the que.docxajoy21
Please answer the three questions completly. I have attached the questions in excel where they need to be answered.
1)
XYZ Company had three defined benefit plans with the following information:
12 Points
Plan 1
Plan 2
Plan 3
Expected Payment over next year
3,500,000
3,500,000
3,500,000
Fair Value of Plan Assets
5,000,000
6,000,000
3,000,000
Projected Benefit Obligation
7,000,000
5,500,000
4,500,000
Record the over/(under) funded status of each plan. Then determine the balance sheet presentation based on the over/(under) funded status. (Input an amount in each yellow cell. If zero, input zero.)
Plan 1
Plan 2
Plan 3
Over/ (Under) Funded Status
Noncurrent Asset
Current Liability**
Noncurrent Liability
** Think about the expected payment over the next year compared to the Plan Assets available.
2)
XYZ Company received the following information from its actuary team for the
10 points
year pertaining to one of its defined benefit plans:
Service Cost
120,000
Interest on Projected Benefit Obligation
55,000
Expected Return on Plan Assets
30,000
Amortization of Prior Service Cost
15,000
Amortization of Actuarial Gain
10,000
Calculate the Pension Expense for the year (show all items included in the calculation):
3)
At the end of year, XYZ Corporation had the following pension related information in addition to the above information:
12 points
12/31/X1
12/31/X2
Fair Value of Plan Assets
405,000
505,000
Projected Benefit Obligation
1,065,000
1,035,000
Funded Status
(660,000)
(530,000)
Record the Necessary Journal Entries:
Entry to record Service Cost, Interest Cost and Return on Plan Assets:
Account Name:
Debit
Credit
Amortization of Prior Service Cost and/or Actuarial Losses:
Account Name:
Debit
Credit
Amortization of Actuarial Gains:
Account Name:
Debit
Credit
4)
a) Identify a US Company that offers a Defined Benefit Plan and review the 10K information for 2016 of the identified company and provide a brief analysis based on footnotes related to the plan.
3 points
b) Include screenshots to report the Funded Status and Pension Expense information for the selected plan.
1 Points
c) Record the associated journal entries based on the screenshots for that company.
12 points
Entry to record Service Cost, Interest Cost and Return on Plan Assets:
Account Name:
Debit
Credit
Amortization of Prior Serv.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Write a program that will test a name) method no sorting routine from.docx
1. Write a program that will test a name) method no sorting
routine from the Library l. Prompt the user to enter a number
and now fill the Array List with that many randomly generated
integer number ranging from 1 to 50 2. Print these numbers
from the ArrayList on the screen. 3. Call the SelectionSort0
method passing this AITayList full with those numbers. 4. Print
the resulting sorted ArrayList of numbers on the screen.
Solution
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Random;
public class Sort {
/**
* main method to test the selectionSort static method
*/
public static void main(String args[]) {
// declare and initialize an array list
ArrayList<Integer> arraylist = new ArrayList<Integer>();
// create a Scanner object
Scanner in = new Scanner(System.in);
Scanner scanner = new Scanner(System.in);
2. System.out.print("Enter number: ");
int number = scanner.nextInt();
System.out.println("The number is: " + number);
// Generate random numbers between 1-50 given in number
variable and add in arrayList
for(int i=0;i<number;i++)
arraylist.add(new Random().nextInt(50)+1);
// print the original array list
System.out.println("Numbers from arraylist are:");
System.out.println(arraylist);
// selection sort it
SelectionSort(arraylist);
// print the sorted array list
System.out.println("Sorted array is:");
System.out.print(arraylist);
}
public static void SelectionSort(ArrayList<Integer> data) {
// just return if the array list is null
if (data == null)
return;
// just return if the array list is empty or only has a single
element
if (data.size() == 0 || data.size() == 1)
return;
// declare an int variable to hold value of index at which
3. the element
// has the smallest value
int smallestIndex;
// declare an int variable to hold the smallest value for each
iteration
// of the outer loop
int smallest;
// for each index in the array list
for (int curIndex = 0; curIndex < data.size(); curIndex++)
{
/* find the index at which the element has smallest value
*/
// initialize variables
smallest = data.get(curIndex);
smallestIndex = curIndex;
for (int i = curIndex + 1; i < data.size(); i++) {
if (smallest > data.get(i)) {
// update smallest
smallest = data.get(i);
smallestIndex = i;
}
}
/* swap the value */
// do nothing if the curIndex has the smallest value
if (smallestIndex == curIndex)
4. ;
// swap values otherwise
else {
int temp = data.get(curIndex);
data.set(curIndex, data.get(smallestIndex));
data.set(smallestIndex, temp);
}
}
}
}
/*output
Enter number:
13
The number is:
13
Numbers from arraylist
are:
[6, 44, 38, 41, 38, 29, 47, 41, 23, 39, 5, 43,
42]
Sorted array
is: