Hi, I would like to test a java program. I am learning linked list and going to make a linked lists for integer nodes.
For instance, I am going to add the numbers 12, 13, and 16 to the list and then display the list contents
and add 15 to the list again and display the list contents and delete 13 from the list
and display the list contents and lastly delete 12 from the list and display the list contents
In order to test like this, with this reference below how can I make a simple code?
If you can please include comments to catch up the codes, it would help me a lot!
public class IntegerNode {
private int item;
private IntegerNode next;
public IntegerNode(int newItem) {
item = newItem;
next = null;
} // end constructor
public IntegerNode(int newItem, IntegerNode nextNode) {
item = newItem;
next = nextNode;
} // end constructor
public void setItem(int newItem) {
item = newItem;
} // end setItem
public int getItem() {
return item;
} // end getItem
public void setNext(IntegerNode nextNode) {
next = nextNode;
} // end setNext
public IntegerNode getNext() {
return next;
} // end getNext
} // end class IntegerNode
In: Computer Science
JAVA
In this PoD you will use an ArrayList to store different pet names (there are no repeats in this list). This PoD can be done in your demo program (where your main method is) – you don’t have to create a separate class for today.
Details
Create an arraylist of Strings, then using a Scanner object you will first read in a number that will tell you how many pet names (one word) you will add to the arraylist.
Once you have added all the names, print the list.
Then read in one more pet name. If this is pet name already exists, do nothing, but if the pet name isn’t in the list, add it to the front of the list (e.g., the first position).
Print the list again.
Next read in two more pet names. If the first pet name is in the list, replace it with the second pet name. If the first pet name isn’t in the list, add the second pet name to the end of the list.
Print the list again.
Input
Example Input:
5 Whiskers Benji Lassie Smokey Bob Triffy Bob Max
Output
Example Output:
[Muffin, Benji, Snowball, Fluffy]
[Muffin, Benji, Snowball, Fluffy]
[Muffin, Benji, Snowball, Whiskers, Fluffy]
In: Computer Science
Java code for creating an Inventory Management System of any company
- designing the data structure(stack, queue, list, sort list, array, array list or linked list) (be flexible for future company growth
Java code for creating an initial list in a structure. Use Array (or ArrayList) or Linkedlist structure whichever you are confident to use. - Implement Stack, Queue, List type structure and proper operation for your application. Do not use any database. All data must use your data structures.
Minimum requirements of the system but not limited to only these:
Menu
1. Search Product
2. Search Product by other attribute
Menu
1. Show entire inventory
2. Show inventory by Manufacturer/Supplier
3. Show inventory by Type
4. Show inventory by Location
5. List products by price
6. List products by supplier
7. List products by availability
8. Show current discount items
Menu
1. Add record/product/part
2. Remove record
3. Change record
Menu for report
1. {make report - e.g. quantity report}
2. {make report - e.g. statistic report}
3. {Alert - Full or low quantity alerting}
In: Computer Science
Introduction:
In this project you will create a generic linked list using
Java Generics.
Description:
Create a generic class called GenLinkedList. GenLinkedList will use nodes
that store a value of the generic type to store its contents.
It should have the following methods. The methods should
all operate on the object making the call (none are static).
Perform checking of the parameters and throw exceptions where
appropriate.
The linked list should be singly-linked.
It should not use sentinel nodes (empty header and tail nodes).
You should strive for an efficient implementation of each method.
7 points each (a-h)
a. addFront
receives an item to add as a parameter, and adds to the front of the list.
b. addEnd
receives an item to add as a parameter, and adds to the end of the list.
c. removeFront
removes a node from the front of the list.
d. removeEnd
removes a node from the end of the list.
e. set
receives a position and item as parameters, sets the element at this
position, provided it is within the current size
f. get
receives a position as a parameter, returns the item at this position,
provided it is within the current size
g. swap
receives two index positions as parameters, and swaps the nodes at
these positions, provided both positions are within the current size
h. shift
receives an integer as a parameter, and shifts the list forward or
backward this number of nodes, provided it is within the current size
11 points each (i-l)
i. removeMatching
receives a value of the generic type as a parameter and removes all
occurrences of this value from the list.
j. erase
receives an index position and number of elements as parameters, and
removes elements beginning at the index position for the number of
elements specified, provided the index position is within the size
and together with the number of elements does not exceed the size
k. insertList
receives a generic List (a Java List) and an index position as parameters,
and copies each value of the passed list into the current list starting
at the index position, provided the index position does not exceed the size.
For example, if list has a,b,c and another list having 1,2,3 is inserted at
position 2, the list becomes a,b,1,2,3,c
l. main
add code to the main method to demonstrate each of your methods
Submit to eLearning:
GenLinkedList.javaIn: Computer Science
def box_sort(names, sizes): Given a list of strings names, a corresponding list of ints sizes, we want to sort items by size so that each of our four sublists contains items in the smallest possible boxes of the following exact sizes: 2, 5, 25, and 50 units. Anything larger than 50 won't fit in a box and is simply ignored at this time. Create and return a list of the four sublists of items.
o Assume: names is a list of strings, and sizes is a list of
ints.
o Restrictions: remember, you can't call any built-in sorting
functions. It's not hard-coding to
directly calculate based on the four given sizes, but keeping a
list of box sizes may actually simplify your code.
box_sort(['a','b','c','d'], [1,5,6,10]) →
[['a'],['b'],['c','d'],[]] box_sort(['a','b','c'], [49,50,51]) →
[[],[],[],['a','b']]
def packing_list(names, sizes, box_size): Given a list of names, a corresponding list of int sizes, and an int box_size, this time we want to keep packing items into boxes of the given box_size until it's full, and then start filling another box of the same size. We return a list of filled boxes as a list of lists of strings. Oversized items are immediately placed into our output in a list by themselves, with an asterisk prefix to indicate that it does not fit. (We continue filling the current box after an oversized item). Items are only considered in their given ordering; do not reorder the items to seek a better packing list! Create and return this list of lists, each one containing items in one box or the single oversized item.
o Assume: names is a list of strings, sizes is a list of ints, and box_size is an int. Order is preserved for all non-oversized items, and oversized items show up immediately before the box that was being filled at the time of consideration.
# boxes of 2+1, 4, and 2.
packing_list(['a','b','c','d'], [2,1,4,2],5) → [['a','b'],['c'],['d']]
# while packing our second box, we find oversized item b, then finish our box.
packing_list(['x','a','b','c'], [5,2,10,3], 5) → [['x'],['*b'],['a','c']]
In: Computer Science
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.)
void pop_Stack (struct linked_list* list, int number) //*This is the function to make and below is the explanation that should be written in given code.
This function removes some nodes in stack manner; the tail of the list will be removed, repeatedly. The parameter (variable number_of_nodes) means the number of nodes that will be removed. When parameter is bigger than 1, popping a node with n times, you do not remove node at one go. If there is only one node in the list, please make sure it frees (de-allocates) both the node and the list. If the list is not a stack type, print the error message “Function pop_Stack: The list type is not a stack” and exit the function. If the number_of_nodes parameter is less than 1 or more than the number of nodes in the stack, respectively print the error message “Function popStack: The number of nodes which will be removed is more than 1” and “Function popStack: The number of nodes which will be removed is more than that in the stack”, then exit the function. The removed nodes should be freed.
Given code is written below,(There is a function to fill in last moment in this code)
linked_list.h: This is the header file of linkLQS.c that declares all the functions and values that are going to be used in linkLQS.c. You do not have to touch this function.
-----------------------------------------------------------------------
(Below code is about linked_list.h)
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct linked_node{
int value;
struct linked_node* next;
struct linked_node* prev;
};
struct linked_list{
int type_of_list; // normal = 0, stack = 1
struct linked_node* head;
struct linked_node* tail;
int number_of_nodes;
};
--------------------------------------------------------
#include "linked_list.h"
#include "string.h"
extern int list_exist;
struct linked_list* create_list (int number_of_nodes, int
list_type)
{
int a[number_of_nodes];
int i, j;
int bFound;
if (number_of_nodes < 1)
{
printf("Function create_list: the
number of nodes is not specified correctly\n");
return NULL;
}
if(list_exist == 1)
{
printf("Function create_list: a
list already exists\nRestart a Program\n");
exit(0);
}
if(list_type != 0 && list_type != 1)
{
printf("Function create_list: the
list type is wrong\n");
exit(0);
}
struct linked_list * new_list = (struct
linked_list*)malloc(sizeof(struct linked_list));
new_list->head = NULL;
new_list->tail = NULL;
new_list->number_of_nodes = 0;
new_list->type_of_list = list_type;
//now put nodes into the list with random
numbers.
srand((unsigned int)time(NULL));
if(list_type == 0)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
insert_node(new_list, new_node);
}
}
else if(list_type == 1)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
push_Stack(new_list, new_node);
}
}
list_exist = 1;
printf("List is created!\n");
return new_list;
}
struct linked_node* create_node (int node_value)//This
functon is the example for reference of the assignment
function
{
struct linked_node* node = (struct
linked_node*)malloc(sizeof(struct linked_node));
node->value = node_value;
node->next = NULL;
node->prev = NULL;
return node;
}
void insert_node(struct linked_list* list, struct
linked_node* node)//This functon is the example for reference of
the assignment function
{
node->next = NULL;
node->prev = NULL;
if(list->head == NULL)
//if head is NULL, tail is also NULL.
{
list->head = node;
list->tail = node;
list_exist = 1;
}
else if(list->head == list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
else if(list->head != list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
(list->number_of_nodes)++;
}
void pop_Stack(struct linked_list* list, int
number)//The function to be written!!
{
~~~~~~~~~~~~~ //your code starts from here
}
In: Computer Science
import java.util.ArrayList;
import java.util.Collections;
public class BirthdayList
{
/**
* This is the main process for class BirthdayList
*/
public static void main()
{
System.out.println("\n\tBegin Birthday List Program\n");
System.out.println("Declare an ArrayList for Birthday
objects");
// 1. TO DO: Declare an ArrayList to store Birthday objects (3
Pts)
// 2. TO DO: Replace the xxx.xxxx() with the appropriate method (2
Pts)
System.out.printf("\nBirthday List is empty: %s\n",
xxx.xxxx() ? "True" : "False");
System.out.println("Add at least five Birthdays to the
list");
// 3. TO DO: Add five or more Birthday objects to the Birthday list
(5 Pts)
// Format is: xxxxx.add(new Birthday("mm/dd","name")):
System.out.printf("Birthday List is empty: %s\n",
bdayList.isEmpty() ? "True" : "False");
// 4. TO DO: Replace the xxx.xxxx() with the appropriate method (2
Pts)
System.out.printf("Birthday list has %d entries\n",
xxx.xxxx());
System.out.println("\nDisplay unsorted Birthday list");
listBirthdays(bdayList);
System.out.println("\nDisplay 3rd Birthday in the listlist");
// 5. TO DO: Replace the xxx.xxxx() with the appropriate method (2
Pts)
System.out.printf("%s\n", xxx.xxxx());
// 6. TO DO: Remove a Birthday object from the list by index;
// Replace the xxx.xxxx() with the appropriate method (2 Pts)
System.out.printf("%s was removed from the list\n",
xxx.xxxx());
System.out.printf("Birthday list has %d entries\n",
bdayList.size());
// 7. TO DO: declare a new Birthday object to replace one in the
list (1 Pts)
// 8. TO DO: Replace (set) an element in the ArrayList with the new
Birthday
// object and complete the System.out.printf statement to display
the original
// Birthday object and the new (replacement) Birthday object (5
Pts)
System.out.printf("\nChange %s to %s\n", xxx.xxxx(),
xxx.xxxx());
System.out.println("\nCopy original Birthday list to new Birthday
list");
// 9. TO DO: Copy the original ArrayList to a new one called
newList (3 Pts)
System.out.println("\nSort new Birthday list");
// 10. TO DO: sort the new ArrayList (2 Pts)
System.out.println("\nDisplay new sorted Birthday list");
listBirthdays(newList);
System.out.println("\n\tEnd Birthday List Program\n");
}
/**
* This function lists all the Birthdays in the list
* @param list - reference to the Birthday ArrayList
*/
public static void listBirthdays(ArrayList<Birthday>
list)
{
int number = 1;
for(Birthday bDay : list)
System.out.printf("%3d - %s\n", number++, bDay.toString());
}
}
import java.lang.String;
public class Birthday implements
Comparable<Birthday>
{
private String date; // Format mm/dd
private String name;
/**
* Constructor for objects of class Birthday
* @param date - in the format mm/dd
* @param name - name associated with date
*/
public Birthday(String date, String name)
{
this.date = date;
this.name = name;
}
/**
* This method provides the comparison function for sorting
* It uses the compareTo method supplied with the String class
* @param other - reference to the Birthday to be compared to
* @return positive value if host date > other date
* negative value if host date < other date
* zero (0) if dates are equal
*/
public int compareTo(Birthday other)
{
return date.compareTo(other.date);
}
/**
* This method overrides the toString() method of the Object
class
* It returns a String with the Birthday informtion
* @return Birthday information as a String
*/
@Override
public String toString()
{
return date + " - " + name;
}
}
In: Computer Science
Mixed-Model ANOVA Article
The first ANOVA was a mixed-model ANOVA to compare the scores of students from each disability group (no disability, reading disability, reading and math disabilities) using test (accomodation condition) as the within-subjects variable and disability as the between-subjects variable. Significant differences were found for the main effects of test, F(4, 184) = 6.55, p < .001, and disability group, F (2, 46) = 23.27, p < .001, and for the interaction between the two variables, F (8, 184) = 2.54, p < .05. Table 5 shows mean scores and standard deviations for each disability group.
A series of one-way ANOVAs was run to follow-up the significant interaction between test condition and disability status. Four of the tests showed significant differences between the groups. Table 5 shows F-values for each test. Tukey HSD tests revealed that on each test that showed a significant difference, students without learning disabilities (LD) scored significantly higher than both students with RD and students with RMD, p < .01. Differences between students with RD and students with RMD were not significant on any test.
Table 5
|
Descriptive Statistics for Scores by Disability and Test Condition |
||||||||||||
|
Disability |
||||||||||||
|
NLD |
RD |
RMD |
Marginal Means |
|||||||||
|
Test |
M |
SD |
M |
SD |
M |
SD |
F |
|||||
|
Standard |
30.88 |
13.23 |
14.14 |
9.75 |
9.70 |
6.21 |
18.33 |
23.16* |
||||
|
Computer-read text |
33.28 |
13.22 |
14.92 |
11.32 |
9.77 |
8.65 |
19.34 |
19.02* |
||||
|
Video |
34.28 |
16.44 |
11.89 |
8.64 |
10.33 |
8.78 |
19.72 |
20.73* |
||||
|
Constructed response |
23.63 |
13.62 |
20.33 |
8.90 |
18.23 |
6.85 |
13.79 |
2.08 |
||||
|
Two accommodations |
20.56 |
11.22 |
16.87 |
7.64 |
17.81 |
5.47 |
18.02 |
1.34 |
||||
|
Comprehensive |
25.13 |
14.19 |
11.64 |
7.61 |
9.40 |
8.04 |
15.36 |
10.81* |
||||
|
Marginal means |
29.44 |
12.78 |
8.49 |
|||||||||
|
NLD = nonLD. RD = reading disability. RMD = reading and math disabilities. |
||||||||||||
|
aFollow-up one-way ANOVAs, df = 2, 46. |
||||||||||||
|
*p < .01. |
||||||||||||
In: Statistics and Probability
For each of the hypotheticals, you should prepare an analysis for each situation explaining what business organization form the business should use. You should define and explain key terms and concepts. Your combined responses on the two business situations should be between about 650 to 850 words. Include a word count in your submission.
You should study Chapters 19 & 20 before working on this assignment and rely on specific information from the text to support your analysis. Detailed analysis is required for this assignment.
Business Situation No.1
Joe operates a local gardening and tree trimming business. Joe also does some light landscaping work for a few of his commercial accounts. Joe is very successful and has enough clients to keep him busy, along with at least three workers, working six days a week. Occasionally, a client rents a piece of equipment from Joe’s business. Clients sometime take their time paying for Joe’s services and, therefore, Joe is sometimes late paying his bills.
Joe’s capital is only about $25,000, most of which consists of his new $20,000 truck and his assortment of lawnmowers, chainsaws, edgers, and gardening equipment. Joe’s wife handles the books, yet is not involved in actual business operations. Should Joe continue to operate his gardening and tree trimming business as a sole proprietorship? Explain.
Business Situation No. 2
As a part of a course assignment, a group of graduate students from JSU have developed a prototype for a new microchip to power the next generation of personal computers. The students have received assurances from venture capitalists to provide whatever financing the students will need to manufacture the chip, provided they receive 51% of the equity. The venture capitalists do not want to interfere in the business operations and have agreed to allow the students to control the operations, provided certain financial objective are achieved. The students and the venture capitalists expect to begin manufacturing of the chip within two years. Based on outside evaluations, the chip should be a success. The students/venture capitalists expect to go public within five years.
What type of business entity should be formed by these graduate students to manufacture and develop the chip (and to conduct further research and development)? Consider whether more than one company should be formed. Explain.
In: Finance
Consider a metal wire that is used as thermistor. When it is connected to a 10.00 V voltage source, at 23.50C a current of 0.4212 A is flowing through the wire. What will the temperature if the current is 0.3818 A. Assume a = 0.00429 (C0)-1
In: Physics