IN JAVA
Minimal Documentation Required (no javadoc)
Purpose
The purpose of this assignment is to introduce you to basic operations on a linked list.
Specifics
Design a program that generates a linked list of randomly generated Integer objects. Present a menu at program start that gives the user the following options (most of these options will have corresponding methods in a Linked List class):
1. Create a new list. The size will be specified by the user, make sure a non-negative value is entered. If there is a pre-existing list when this option is chosen, make sure you delete the contents of that list before creating your new list.
2. Sort the list. How you implement this is up to you. You can insert items in the list such that the list is always in sorted order or you can write a sort routine. You may not call a sort routine provided by the Java API.
3. Print the list (to the screen), one number per line.
4. Print the list in reverse order (to the screen), one number per line.
5. Generate a sub-list that contains all the even numbers in the current list. This list should be returned and the contents should be displayed (to the screen), one number per line.
6. Print the contents of every "nth" node in the list. Obtain the "n" from the user, ensure it is greater than 0.
7. Delete node(s) containing an integer value entered by the user. You should report how many were deleted to the user.
8. Delete the contents of the current list.
9. Quit
You may use any linked list implementation you wish (singly linked, doubly linked, dummy head node, circular).
In addition to your LinkedList class, include a driver file called ListTester that will contain the menu and anything else you deem necessary (perhaps a utility to generate random Integers...).
Keep things modular and encapsulate your data properly - do not let anything outside the Linked List class have direct access to any of the nodes.
Do not accept Invalid input of any type from the user and do not let user input crash your program.
PLEASE IMPLEMENT ALL
In: Computer Science
IN JAVA
If a list is received for which the last String is in the word list, this method should recursively call itself on a list consisting of all but the last word. If the recursive call returns a String (not null), add the last word back to the end of the String and return it. This method should not contain any loops.
In: Computer Science
/**
* This class maintains an arbitrary length list of integers.
*
* In this version:
* 1. The size of the list is fixed after the object is
created.
* 2. The code assumes there is at least one element in the
list.
*
* This class introduces the use of loops.
*
* @author Raymond Lister
* @version September 2015
*
*/
public class ListOfNVersion02PartB
{
public int[] list; // Note: no "= {0, 1, 2, 3}" now
/**
* This constructor initializes the list to the same values
* as in the parameter.
*
* @param element the initial elements for the list
*/
public ListOfNVersion02PartB(int [] element)
{
// make "list" be an array the same size as "element"
list = new int[element.length];
for (int i = 0; i {
list[i] = element[i];
}
// add whatever code is required to complete the constructor
} // constructor ListOfNVersion01Skeleton(int [] element)
/**
* @return the first element in the list
*/
public int getFirst()
{
return list[0];
} // method getFirst
/**
* In ListOfN in this test, the toString method
* should return a String such that:
*
* 1. The String begins with an open brace "{" followed
* IMMEDIATELY (i.e. no space) by the first element
* of the list.
* 2. All remaining elements of the list are preceded by
* ", " (i.e. a comma folowed by a SINGLE space).
* 3. The String ends with a closing brace "}".
*
* e.g. "{1, 2, 3, 4}"
*
* @return A summary of the contents of the list.
*/
public String toString()
{
String s = "{"; // role: gatherer
for (int i = 0; i < list.length; i++)
if (i == 0)
{
s += list[i];
}
else
{
s += ", " + list[i];
}
s += "}";
// add and/or modify code to complete the method
return s;
} // method toString
/**
* @return the sum of the elements of the array
*/
public int sum()
{
int sum = 0;
for (int i = 0; i < list.length; i++)
{
sum += list[i];
}
// add and/or modify code to complete the method
return sum;
} // method sum
/**
* @return the number of times the replacement was made (i.e. 0 or
1)
*
* @param replaceThis the element to be replaced
* @param withThis the replacement
*/
public int replaceOnce(int replaceThis, int withThis)
{
for (int i = 0; i < list.length; i++)
{
if( list[i] == replaceThis)
{
list[i] = withThis;
return 1;
}
}
// add and/or modify code to complete the method
return 0;
} // method replaceOnce
/**
* @return the value of the smallest element in the array
*/
public int minVal()
{
int min = Integer.MAX_VALUE;
for (int i = 0; i < list.length; i++)
if (list[i] < min)
{
min = list[i];
}
// add and/or modify code to complete the method
return min;
} // method minVal
/**
* Inserts an element in the first position. The elements already in
the
* list are pushed up one place, and the element that was
previously
* last is lost from the list.
*
* @param newElement the element to be inserted
*/
public void insertFirst(int newElement)
{
int temp = list[0];
list[0] = newElement;
for (int i = 1; i < list.length-1; ++i)
{
int curr = list[i];
list[i] = temp;
temp = curr;
}
// add and/or modify code to complete the method
} // method insertFirst
/*
* This method is NOT examinable in this test.
*
* Swaps two elements in the list.
*
* @param i the position of one of the elements to be swapped
* @param j the position of one of the elements to be swapped
*/
private void swap(int i, int j)
{
int temp; // role: temporary
temp = list[i];
list[i] = list[j];
list[j] = temp;
} // method swap
/**
* "So the first shall be last, and the last first"
* -- The Christian Bible, book of Matthew 20:16
*/
public void reverse()
{
for (int i = 0, j = list.length - 1; i < list.length / 2
&& j > list.length / 2; i++, j--)
{
swap(i, j);
// add and/or modify code to complete the method
} // method reverse
}} // class ListOfNVersion02PartB
How do i fix this??:
Failed: Check insertFirst. expected:<{7,[1,4],2}> but was:<{7,[4,1],2}>
I figured out my mistake, thank you anyway!
(the reverse method needed a while loop and fixed my insertFirst method )
In: Computer Science
Note: This problem is for the 2018 tax year.
Lance H. and Wanda B. Dean are married and live at 431 Yucca Drive, Santa Fe, NM 87501. Lance works for the convention bureau of the local Chamber of Commerce, while Wanda is employed part-time as a paralegal for a law firm.
During 2018, the Deans had the following receipts:
|
Wanda was previously married to John Allen. When they divorced several years ago, Wanda was awarded custody of their two children, Penny and Kyle. (Note: Wanda has never issued a Form 8332 waiver.) Under the divorce decree, John was obligated to pay alimony and child support—the alimony payments were to terminate if Wanda remarried.
In July, while going to lunch in downtown Santa Fe, Wanda was injured by a tour bus. As the driver was clearly at fault, the owner of the bus, Roadrunner Touring Company, paid her medical expenses (including a one-week stay in a hospital). To avoid a lawsuit, Roadrunner also transferred $90,000 to her in settlement of the personal injuries she sustained.
The Deans had the following expenditures for 2018:
|
The life insurance policy was taken out by Lance several years ago and designates Wanda as the beneficiary. As a part-time employee, Wanda is excluded from coverage under her employer's pension plan. Consequently, she provides for her own retirement with a traditional IRA obtained at a local trust company. Because the mayor is a member of the local Chamber of Commerce, Lance felt compelled to make the political contribution.
The Deans' household includes the following, for whom they provide more than half of the support:
|
Penny graduated from high school on May 9, 2018, and is undecided about college. During 2018, she earned $8,500 (placed in a savings account) playing a harp in the lobby of a local hotel. Wayne is Wanda's widower father who died on January 20, 2018. For the past few years, Wayne qualified as a dependent of the Deans.
Federal income tax withheld is $5,200 (Lance) and $2,100 (Wanda). The proper amount of Social Security and Medicare tax was withheld.
Required:
Determine the Federal income tax for 2018 for the Deans on a joint return by providing the following information that would appear on Form 1040 and Schedule A. They do not want to contribute to the Presidential Election Campaign Fund. All members of the family had health care coverage for all of 2018. If an overpayment results, it is to be refunded to them.
Make realistic assumptions about any missing data.
Enter all amounts as positive numbers.
If an amount box does not require an entry or the answer is zero, enter "0".
When computing the tax liability, do not round your immediate calculations. If required round your final answers to the nearest dollar.
In: Accounting
USING PYTHON
Write a program to create a number list. It will call a function to calculate the average values in the list.
Define main ():
Declare variables and initialize them
Create a list containing numbers (int/float)
Call get_avg function that will return the calculated average values in the list.
Use a for loop to loop through the values in the list and calculate avg
End main()
In: Computer Science
CCC3 In November 2017, after having incorporated Cookie Creations Inc., Natalie begins operations. She has decided not to pursue the offer to supply cookies to Biscuits. Instead, she will focus on offering cooking classes. The following events occur.
1 Natalie purchases $5000 of Cookie Creations’ common stock.
2 Natalie teaches a group of elementary school students how to make Santa Claus cookies. At the end of the class, Natalie leaves an invoice for $3000- with the school principal. The principal says that he will pass it along to the business off
3 ice and it will be paid some time in the future
4 Cookie Creations receives $750 in advance from the local school board for five classes that the company will give during December and January.
5 Natalie receives a $500 invoice for use of her cell phone. She uses the cell phone exclusively for Cookie Creations Inc. business
11 Cookie Creations purchases paper and other office supplies for $2000. (Use Supplies.)
15 Natalie purchased equipment $3000 . Will pay for the equipment in 30days
15 . Natalie signs a note with the bank for $2,000 cash, for a two-year, 12% note payable. Interest and the principal are repayable at maturity.
15 Pays the cell phone invoice outstanding.
18 Natalie did her first class . She received $1000 cash.
23 Additional revenue during the month for cookie-making classes amounts to $4,000. (Natalie ha $3,000 in cash has been collected and $1,000 is still outstanding.
23 Received a bill from her accountant for $ 800
23 Issues a check to Natalie’s assistant for $800.
28 Pays a dividend of $500 to the common shareholder
30 Natalie received an advertising bill for $ 1500.
30 Cookie Creations pays $1,200 for a one-year insurance policy.
30 Cookie Creations receives a check for the amount due from the neighborhood school for the class given on November 2.
Additional Information
1. Monthly Depreciation on the equipment is $ 100
2. Accrued interest on the loan is $ 15
3. There were $500 of office supplies left at the end of the month
4. One month of insurance policy expired
5. Earned $ 300 for the entry on Nov 3
Required :
1. Journalize the above transactions
2. Post to ledger
3. Do a trial balance
4. Record adjusting entries in journal and post to the ledger
5. Adjusted trial balance
6. Do a income statement ,balance sheet and retained earnings statement
In: Accounting
Complete the following method in java:
public static List<Integer> runningMedianOfThree(List items)
Create and return a new List<Integer> instance (of any subtype of List of your choice) whose first two elements are the same as that of original items, after which each element equals the median of the three elements in the original list ending in that position. For example, when called with a list that prints out as [5, 2, 9, 1, 7, 4, 6, 3, 8], this method would return an object of type List<Integer> that prints out as [5, 2, 5, 2, 7, 4, 6, 4, 6].
In: Computer Science
IN C++
Write a program to find the number of comparisons using
binarySearch and the sequential search algorithm as follows:
Suppose list is an array of 1000 elements.
3 Search list for some items as follows:
a. Use the binary search algorithm to search the list. (You may
need to modify the algorithm given in this chapter to count the
number of comparisons.)
b. Use the binary search algorithm to search the list, switching to
a sequentialsearch when the size of the search list reduces to less
than 15. (Use the sequential search algorithm for a sorted
list.)
Print the number of comparisons for Questions 3a and b. If the item
is found in the list, then print its position.
In: Computer Science
Question Four
Eric Aboagye was a 29-year-old math teacher at Ako Basic School in Pru District. He empathized with his students and was devoted to their success. A colleague described Aboagye as a “star teacher” and a “very hard worker, who will go the extra mile.” Aboagye was a teacher when Mary Afenya was Pru District’s school superintendent. Afenya set accountability measures for the Pru District school district and created performance objectives for the schools. Teacher evaluations were linked to students’ performance on standardized tests. Schools whose students did not make appropriate progress toward the standardized test goals received escalating sanctions that culminated in replacement of teachers and other staff, and restructuring or closing of the school. Ako Basic School had been classified as “a school in need of improvement” for the previous five years. Unless 58 percent of students passed the math portion of the standardized test and 67 percent passed the language arts portion, Ako Basic School could be closed down. Its students would be separated and bussed across town to different schools. Aboagye pushed his students to work harder than they ever had in preparing for the test. But he knew that it would be very difficult for many of them to pass. Mr. Mensah, the new principal of Ako Basic School, had heard that teachers in the elementary schools that fed into Ako had changed their students’ answers on the standardized tests under the guise of erasing stray pencil marks. Mr. Mensah asked Aboagye and other teachers to do the same. Aboagye found the exams of students who needed to get a few more questions right in order to pass. He changed their answers. If he did not change their scores, Aboagye feared that his students would lapse into “why try” attitudes. They would lose their neighborhood school and the community that had developed within it. Thanks to Aboagye and other teachers, students of Ako did better than ever on the standardized tests. Salomey, a former student at Ako at the time, recalled, “Everyone was jumping up and down,” after a teacher announced the school had met the requirements. The same process of changing answers continued at Ako for about five years. In the fifth year, nine other teachers were helping Aboagye change answers. Later in that year, the investigation unit of the Ghana Education Service (GES) visited Ako and other Pru District schools. The results of the investigation showed that, teachers and administrators at 20 schools had cheated in the manner that Aboagye had. Also, 78 teachers who had confessed or been accused of cheating were placed on administrative leave, including Aboagye. Later, Aboagye’ employment was terminated. (All characters used in the case are hypothetical)
1. In this case study, indicate and explain two benefits and three disadvantages of falsifying the results (make reference to relevant ethical theories and/or approaches).
2. Do you think cheating can ever be ethically justifiable? Why or why not (Explain three reasons – make reference to relevant ethical approaches)?
In: Operations Management
In: Statistics and Probability