SlideShare a Scribd company logo
1 of 17
/**
* This class maintains a list of 4 integers.
*
* This list is simple and unusual in it always contains exactly
the
* same number of elements. Later, when we know more Java,
we will
* study classes where the number of elements may vary.
*
* In this version 2, we use variables in the subscripts.
*
* @author Raymond Lister
* @version August 2014
*
*/
public class ListOf4V2PartA
{
private static final int listSize = 4;
private int[] list = {0, 1, 2, 3};
/**
* A constructor for objects of class ListOf4, which takes four
parameters
*
* @param one an initial element for the list, the first element.
* @param two an initial element for the list
* @param three an initial element for the list
* @param four an initial element for the list, the last element.
*/
public returnTypeIfAny nameOfConstructor(int one, int two,
int three, int four)
{
add whatever code is required to this constructor body
to initialize the four elements of array "list" to
the values given in the parameters.
} // constructor ListOf4(int one, int two, int three, int four)
/**
* @return the number of elements stored in this list
*/
public returntype getListSize(parametersIfAny)
{
return something;
} // method getListSize
/**
* @return the last element in the list
*/
public returntype getLast(parametersIfAny)
{
add whatever code is required here in the method body
} // method getLast
/**
* prints the contents of the list, in order from first to last
*/
public returntype printList(para metersIfAny)
{
// with variable subscripts ...
System.out.print("{");
int i = initial value; // role: stepper
System.out.print(list[array subscript]);
i = updated value;
System.out.print(", " + list[array subscript]);
copy and paste some of the code above, as many times as
required
System.out.print("}");
} // method printList
/**
* prints the contents of the list, in order from first to last, and
* then moves the cursor to the next line
*/
public void printlnList()
{
printList();
System.out.println();
} // method printlnList
/**
* @return the number of times the element occurs in the list
*
* @param element the element to be counted
*/
public returntype countElement(parametersIfAny)
{
int count = 0; // role: stepper
// with variable subscripts ...
int i = initial; // role: stepper
if ( list[subscript] == something ) doSomething;
i = updatedVal;
copy and paste some of the code above, as many times as
required
return returnValue;
} // method countElement
/**
* @return the number of times the replacement was made
*
* @param replaceThis the element to be replaced
* @param withThis the replacement
*/
public returntype replaceAll(parametersIfAny)
{
int count = 0; // role: stepper; number of replacements made
// with variable subscripts ...
int i = beginning value; // role: stepper
if ( list[sub] == something )
{
list[sub] = something;
increment something;
}
increment something;
copy and paste some of the code above, as many times as
required
return count;
} // method replaceAll
/**
* @return the first position in list occupied by the parameter
value, or -1 if it is not found
*
* @param findThis the value to be found
*/
public returntype findUnSorted(parametersIfAny)
{
// This algorithm is known as "linear search"
// with variable subscripts ...
int pos = initialValueForPos;
if ( list[subscript] == something ) return whatever;
pos = updatedVal;
copy and paste some of the code above, as many times as
required
return notFound;
} // method findUnSorted
/**
* @return the position of the smallest element in the array
*/
public returntype minPos(parametersIfAny)
{
int mostWantedHolder = initial value; // role: Most-wanted
holder
// variable mostWantedHolder remembers the position of the
// smallest number seen so far
// with variable subscripts ...
int i = initial value; // role: stepper
if ( list[subscript1] < list[subscript2] )
{
update mostWantedHolder
}
i = newVal;
copy and paste some of the code above, as many times as
required
return theAppropriateValue;
} // method minPos
/**
* 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
*/
public void swap(int i, int j)
{
int temp; // role: temporary
temp = list[i];
list[i] = list[j];
list[j] = temp;
} // method swap
/**
* Orders the elements of the list, with the first element smallest
and the
* last element largest. Does this using the bubblesort
algorithm.
*/
public returntype sortBubble(parametersIfAny)
{
/* This implementation uses the bubble sort algorithm. For an
explanation
* of how bubblesort works, google ...
* bubblesort java
*/
// with variable subscripts ...
int i = initialize i; // role: stepper
if ( list[subscript1] > list[subscript2] ) swap(subscript3,
subscript4);
i = nextVal;
copy and paste some of the code above, as many times as
required
// At this point, the largest element must be in list[3].
reinitialize i
copy and paste some of the code above, as many times as
required
// At this point, the second largest element must be in list[2].
reinitialize i
copy and paste some of the code above, as many times as
required
// At this point, the smallest element must be in list[0].
} // method sortBubble
} // class ListOf4V2
Solution
/**
*
* This class maintains a list of 4 integers.
*
* This list is simple and unusual in it always contains exactly
the same number
* of elements. Later, when we know more Java, we will study
classes where the
* number of elements may vary.
*
* In this version 2, we use variables in the subscripts.
*
* @author Raymond Lister
* @version August 2014
*
*/
public class ListOf4V2PartA {
private static final int listSize = 4;
private int[] list = { 0, 1, 2, 3 };
/**
* A constructor for objects of class ListOf4, which takes four
parameters
*
* @param one
* an initial element for the list, the first element.
* @param two
* an initial element for the list
* @param three
* an initial element for the list
* @param four
* an initial element for the list, the last element.
*/
public ListOf4V2PartA(int one, int two, int three, int four) {
list[0] = one;
list[1] = two;
list[2] = three;
list[3] = four;
} // constructor ListOf4(int one, int two, int three, int four)
/**
* @return the number of elements stored in this list
*/
public int getListSize() {
return list.length;
} // method getListSize
/**
* @return the last element in the list
*/
public int getLast() {
// add whatever code is required here in the method body
return list[list.length - 1];
} // method getLast
/**
* prints the contents of the list, in order from first to last
*/
public void printList() {
// with variable subscripts ...
System.out.print("{");
for (int i = 0; i < list.length; i++) {
if (i == 0)
System.out.print(list[i]);
else
System.out.print(", " + list[i]);
}
System.out.print("}");
} // method printList
/**
* prints the contents of the list, in order from first to last,
and then
* moves the cursor to the next line
*/
public void printlnList() {
printList();
System.out.println();
} // method printlnList
/**
* @return the number of times the element occurs in the list
*
* @param element
* the element to be counted
*/
public int countElement(int element) {
int count = 0; // role: stepper
// with variable subscripts ...
for (int i = 0; i < list.length; i++) {
if (list[i] == element)
count++;
}
return count;
} // method countElement
/**
* @return the number of times the replacement was made
*
* @param replaceThis
* the element to be replaced
* @param withThis
* the replacement
*/
public int replaceAll(int replaceThis, int withThis) {
int count = 0; // role: stepper; number of replacements
made
// with variable subscripts ...
for (int i = 0; i < list.length; i++) {
if (list[i] == replaceThis) {
list[i] = withThis;
count++;
}
}
return count;
} // method replaceAll
/**
* @return the first position in list occupied by the parameter
value, or -1
* if it is not found
*
* @param findThis
* the value to be found
*/
public int findUnSorted(int findThis) {
// This algorithm is known as "linear search"
// with variable subscripts ...
int pos = -1;
for (int i = 0; i < list.length; i++) {
if (list[i] == findThis)
return i;
}
return pos;
} // method findUnSorted
/**
* @return the position of the smallest element in the array
*/
public int minPos() {
int mostWantedHolder = list[0]; // role: Most-wanted
holder
// variable mostWantedHolder remembers the position of
the
// smallest number seen so far
int pos = 0;
// with variable subscripts ...
for (int i = 0; i < list.length; i++) {
if (list[i] < mostWantedHolder) {
mostWantedHolder = list[i];
pos = i;
}
}
return pos;
} // method minPos
/**
* 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
*/
public void swap(int i, int j) {
int temp; // role: temporary
temp = list[i];
list[i] = list[j];
list[j] = temp;
}
/**
* Orders the elements of the list, with the first element
smallest and the
* last element largest. Does this using the bubblesort
algorithm.
*/
public void sortBubble() {
/*
* This implementation uses the bubble sort algorithm. For
an
* explanation of how bubblesort works, google ...
bubblesort java
*/
for (int i = (list.length - 1); i >= 0; i--) {
for (int j = 1; j <= i; j++) {
if (list[j - 1] > list[j]) {
int temp = list[j - 1];
list[j - 1] = list[j];
list[j] = temp;
}
}
}
// At this point, the smallest element must be in list[0].
} // method sortBubble
} // class ListOf4V2
/**
* @author
*
*/
public class TestListOf4V2PartA {
/**
* @param args
*/
public static void main(String[] args) {
ListOf4V2PartA listOf4V2PartA = new ListOf4V2PartA(5,
15, 4, 13);
System.out.println("getListSize()-->" +
listOf4V2PartA.getListSize());
System.out.println("getLast()-->" +
listOf4V2PartA.getLast());
listOf4V2PartA.printList();
listOf4V2PartA.printlnList();
System.out.println("countElement()-->"
+ listOf4V2PartA.countElement(15));
System.out.println("replaceAll()-->"
+ listOf4V2PartA.replaceAll(13, 14));
System.out.println("findUnSorted()-->"
+ listOf4V2PartA.findUnSorted(13));
System.out.println("minPos()-->" +
listOf4V2PartA.minPos());
System.out.println("After swap 1 and 2:");
listOf4V2PartA.swap(1, 2);
listOf4V2PartA.printlnList();
System.out.println("After sorting : ");
listOf4V2PartA.sortBubble();
listOf4V2PartA.printList();
}
}
OUTPUT:
getListSize()-->4
getLast()-->13
{5, 15, 4, 13}{5, 15, 4, 13}
countElement()-->1
replaceAll()-->1
findUnSorted()-->-1
minPos()-->2
After swap 1 and 2:
{5, 4, 15, 14}
After sorting :
{4, 5, 14, 15}

More Related Content

Similar to Maintains List of 4 Integers

please follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfplease follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfIan5L3Allanm
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfezonesolutions
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfudit652068
 
Written in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdfWritten in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdfsravi07
 
Written in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfWritten in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfsravi07
 
Write a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdfWrite a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdfhardjasonoco14599
 
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdfganisyedtrd
 
I need help with the 2nd TODO comment and the other comments Ill.pdf
I need help with the 2nd TODO comment and the other comments Ill.pdfI need help with the 2nd TODO comment and the other comments Ill.pdf
I need help with the 2nd TODO comment and the other comments Ill.pdfEye2eyeopticians10
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
 
helpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdfhelpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdfalmonardfans
 
for initializer_list include ltinitializer_listgt .pdf
 for initializer_list include ltinitializer_listgt .pdf for initializer_list include ltinitializer_listgt .pdf
for initializer_list include ltinitializer_listgt .pdfajay1317
 
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfNeed Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfEdwardw5nSlaterl
 
-- Reminder that your file name is incredibly important- Please do not.docx
-- Reminder that your file name is incredibly important- Please do not.docx-- Reminder that your file name is incredibly important- Please do not.docx
-- Reminder that your file name is incredibly important- Please do not.docxAdamq0DJonese
 
Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfStewart29UReesa
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdftesmondday29076
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docxajoy21
 
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfJAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfsuresh640714
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxVictorzH8Bondx
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfmohammadirfan136964
 
you will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfyou will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfclearvisioneyecareno
 

Similar to Maintains List of 4 Integers (20)

please follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdfplease follow all instructions and answer the inbedded questions- and.pdf
please follow all instructions and answer the inbedded questions- and.pdf
 
please i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdfplease i need help Im writing a program to test the merge sort alg.pdf
please i need help Im writing a program to test the merge sort alg.pdf
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdf
 
Written in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdfWritten in C- requires linked lists- Please answer the 4 questions and.pdf
Written in C- requires linked lists- Please answer the 4 questions and.pdf
 
Written in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdfWritten in C- requires linked lists- Please answer the 4 questions and (1).pdf
Written in C- requires linked lists- Please answer the 4 questions and (1).pdf
 
Write a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdfWrite a function which return a list of all of the n element subset .pdf
Write a function which return a list of all of the n element subset .pdf
 
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
-- Write the compiler used- Visual studio or gcc -- Reminder that your.pdf
 
I need help with the 2nd TODO comment and the other comments Ill.pdf
I need help with the 2nd TODO comment and the other comments Ill.pdfI need help with the 2nd TODO comment and the other comments Ill.pdf
I need help with the 2nd TODO comment and the other comments Ill.pdf
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
 
helpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdfhelpInstructionsAdd the function max as an abstract function to .pdf
helpInstructionsAdd the function max as an abstract function to .pdf
 
for initializer_list include ltinitializer_listgt .pdf
 for initializer_list include ltinitializer_listgt .pdf for initializer_list include ltinitializer_listgt .pdf
for initializer_list include ltinitializer_listgt .pdf
 
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdfNeed Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
Need Help!! C++ #include-iostream- #include-linkedlist-h- using namesp.pdf
 
-- Reminder that your file name is incredibly important- Please do not.docx
-- Reminder that your file name is incredibly important- Please do not.docx-- Reminder that your file name is incredibly important- Please do not.docx
-- Reminder that your file name is incredibly important- Please do not.docx
 
Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdf
 
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdfDividing a linked list into two sublists of almost equal sizesa. A.pdf
Dividing a linked list into two sublists of almost equal sizesa. A.pdf
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docx
 
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfJAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
 
Note- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docxNote- Can someone help me with the private E get(int index- int curren (1).docx
Note- Can someone help me with the private E get(int index- int curren (1).docx
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
 
you will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdfyou will implement some sorting algorithms for arrays and linked lis.pdf
you will implement some sorting algorithms for arrays and linked lis.pdf
 

More from Komlin1

Theodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docx
Theodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docxTheodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docx
Theodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docxKomlin1
 
Theory and Research Related to Social Issue By now, you have had t.docx
Theory and Research Related to Social Issue By now, you have had t.docxTheory and Research Related to Social Issue By now, you have had t.docx
Theory and Research Related to Social Issue By now, you have had t.docxKomlin1
 
Theory and the White-Collar OffenderOur previous week’s discussion.docx
Theory and the White-Collar OffenderOur previous week’s discussion.docxTheory and the White-Collar OffenderOur previous week’s discussion.docx
Theory and the White-Collar OffenderOur previous week’s discussion.docxKomlin1
 
There are 2 questions part A and B. All questions and relevant att.docx
There are 2 questions part A and B. All questions and relevant att.docxThere are 2 questions part A and B. All questions and relevant att.docx
There are 2 questions part A and B. All questions and relevant att.docxKomlin1
 
There are 2 discussions Topic 1 & Topic 2 (They both require refere.docx
There are 2 discussions Topic 1 & Topic 2 (They both require refere.docxThere are 2 discussions Topic 1 & Topic 2 (They both require refere.docx
There are 2 discussions Topic 1 & Topic 2 (They both require refere.docxKomlin1
 
Theoretical PerspectiveIdentify at least one human developme.docx
Theoretical PerspectiveIdentify at least one human developme.docxTheoretical PerspectiveIdentify at least one human developme.docx
Theoretical PerspectiveIdentify at least one human developme.docxKomlin1
 
THEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docx
THEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docxTHEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docx
THEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docxKomlin1
 
Theories of Behavior TimelineComplete the following tabl.docx
Theories of Behavior TimelineComplete the following tabl.docxTheories of Behavior TimelineComplete the following tabl.docx
Theories of Behavior TimelineComplete the following tabl.docxKomlin1
 
Thematic Issues Globalization; Islam & the West.docx
Thematic Issues Globalization; Islam & the West.docxThematic Issues Globalization; Islam & the West.docx
Thematic Issues Globalization; Islam & the West.docxKomlin1
 
The written portion of the research paper should be 9-11 pages in le.docx
The written portion of the research paper should be 9-11 pages in le.docxThe written portion of the research paper should be 9-11 pages in le.docx
The written portion of the research paper should be 9-11 pages in le.docxKomlin1
 
The World since 1945Country Report- SAUDI ARABIA     Histo.docx
The World since 1945Country Report- SAUDI ARABIA     Histo.docxThe World since 1945Country Report- SAUDI ARABIA     Histo.docx
The World since 1945Country Report- SAUDI ARABIA     Histo.docxKomlin1
 
The world runs on Big Data.  Traditionally, Data has been expressed .docx
The world runs on Big Data.  Traditionally, Data has been expressed .docxThe world runs on Big Data.  Traditionally, Data has been expressed .docx
The world runs on Big Data.  Traditionally, Data has been expressed .docxKomlin1
 
the    1.The collaborative planning Methodology is the f.docx
the    1.The collaborative planning Methodology is the f.docxthe    1.The collaborative planning Methodology is the f.docx
the    1.The collaborative planning Methodology is the f.docxKomlin1
 
The word stereotype originally referred to a method used by printers.docx
The word stereotype originally referred to a method used by printers.docxThe word stereotype originally referred to a method used by printers.docx
The word stereotype originally referred to a method used by printers.docxKomlin1
 
The Value of Critical Thinking  Please respond to the followin.docx
The Value of Critical Thinking  Please respond to the followin.docxThe Value of Critical Thinking  Please respond to the followin.docx
The Value of Critical Thinking  Please respond to the followin.docxKomlin1
 
The Value Chain Concept Please respond to the following·.docx
The Value Chain Concept Please respond to the following·.docxThe Value Chain Concept Please respond to the following·.docx
The Value Chain Concept Please respond to the following·.docxKomlin1
 
The wealth and energy between 1880 and 1910 was a unique and dynamic.docx
The wealth and energy between 1880 and 1910 was a unique and dynamic.docxThe wealth and energy between 1880 and 1910 was a unique and dynamic.docx
The wealth and energy between 1880 and 1910 was a unique and dynamic.docxKomlin1
 
The Value of Research in Social PolicyWhile research can be intere.docx
The Value of Research in Social PolicyWhile research can be intere.docxThe Value of Research in Social PolicyWhile research can be intere.docx
The Value of Research in Social PolicyWhile research can be intere.docxKomlin1
 
The United States’ foreign policy until the end of the nineteenth ce.docx
The United States’ foreign policy until the end of the nineteenth ce.docxThe United States’ foreign policy until the end of the nineteenth ce.docx
The United States’ foreign policy until the end of the nineteenth ce.docxKomlin1
 
The Value Chain Concept Please respond to the followingDescribe.docx
The Value Chain Concept Please respond to the followingDescribe.docxThe Value Chain Concept Please respond to the followingDescribe.docx
The Value Chain Concept Please respond to the followingDescribe.docxKomlin1
 

More from Komlin1 (20)

Theodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docx
Theodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docxTheodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docx
Theodore Robert (Ted) BundyReview the case of Theodore Robert (Ted.docx
 
Theory and Research Related to Social Issue By now, you have had t.docx
Theory and Research Related to Social Issue By now, you have had t.docxTheory and Research Related to Social Issue By now, you have had t.docx
Theory and Research Related to Social Issue By now, you have had t.docx
 
Theory and the White-Collar OffenderOur previous week’s discussion.docx
Theory and the White-Collar OffenderOur previous week’s discussion.docxTheory and the White-Collar OffenderOur previous week’s discussion.docx
Theory and the White-Collar OffenderOur previous week’s discussion.docx
 
There are 2 questions part A and B. All questions and relevant att.docx
There are 2 questions part A and B. All questions and relevant att.docxThere are 2 questions part A and B. All questions and relevant att.docx
There are 2 questions part A and B. All questions and relevant att.docx
 
There are 2 discussions Topic 1 & Topic 2 (They both require refere.docx
There are 2 discussions Topic 1 & Topic 2 (They both require refere.docxThere are 2 discussions Topic 1 & Topic 2 (They both require refere.docx
There are 2 discussions Topic 1 & Topic 2 (They both require refere.docx
 
Theoretical PerspectiveIdentify at least one human developme.docx
Theoretical PerspectiveIdentify at least one human developme.docxTheoretical PerspectiveIdentify at least one human developme.docx
Theoretical PerspectiveIdentify at least one human developme.docx
 
THEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docx
THEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docxTHEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docx
THEIEPGOALSSHOULD BE WRITTEN INAWORDDO.docx
 
Theories of Behavior TimelineComplete the following tabl.docx
Theories of Behavior TimelineComplete the following tabl.docxTheories of Behavior TimelineComplete the following tabl.docx
Theories of Behavior TimelineComplete the following tabl.docx
 
Thematic Issues Globalization; Islam & the West.docx
Thematic Issues Globalization; Islam & the West.docxThematic Issues Globalization; Islam & the West.docx
Thematic Issues Globalization; Islam & the West.docx
 
The written portion of the research paper should be 9-11 pages in le.docx
The written portion of the research paper should be 9-11 pages in le.docxThe written portion of the research paper should be 9-11 pages in le.docx
The written portion of the research paper should be 9-11 pages in le.docx
 
The World since 1945Country Report- SAUDI ARABIA     Histo.docx
The World since 1945Country Report- SAUDI ARABIA     Histo.docxThe World since 1945Country Report- SAUDI ARABIA     Histo.docx
The World since 1945Country Report- SAUDI ARABIA     Histo.docx
 
The world runs on Big Data.  Traditionally, Data has been expressed .docx
The world runs on Big Data.  Traditionally, Data has been expressed .docxThe world runs on Big Data.  Traditionally, Data has been expressed .docx
The world runs on Big Data.  Traditionally, Data has been expressed .docx
 
the    1.The collaborative planning Methodology is the f.docx
the    1.The collaborative planning Methodology is the f.docxthe    1.The collaborative planning Methodology is the f.docx
the    1.The collaborative planning Methodology is the f.docx
 
The word stereotype originally referred to a method used by printers.docx
The word stereotype originally referred to a method used by printers.docxThe word stereotype originally referred to a method used by printers.docx
The word stereotype originally referred to a method used by printers.docx
 
The Value of Critical Thinking  Please respond to the followin.docx
The Value of Critical Thinking  Please respond to the followin.docxThe Value of Critical Thinking  Please respond to the followin.docx
The Value of Critical Thinking  Please respond to the followin.docx
 
The Value Chain Concept Please respond to the following·.docx
The Value Chain Concept Please respond to the following·.docxThe Value Chain Concept Please respond to the following·.docx
The Value Chain Concept Please respond to the following·.docx
 
The wealth and energy between 1880 and 1910 was a unique and dynamic.docx
The wealth and energy between 1880 and 1910 was a unique and dynamic.docxThe wealth and energy between 1880 and 1910 was a unique and dynamic.docx
The wealth and energy between 1880 and 1910 was a unique and dynamic.docx
 
The Value of Research in Social PolicyWhile research can be intere.docx
The Value of Research in Social PolicyWhile research can be intere.docxThe Value of Research in Social PolicyWhile research can be intere.docx
The Value of Research in Social PolicyWhile research can be intere.docx
 
The United States’ foreign policy until the end of the nineteenth ce.docx
The United States’ foreign policy until the end of the nineteenth ce.docxThe United States’ foreign policy until the end of the nineteenth ce.docx
The United States’ foreign policy until the end of the nineteenth ce.docx
 
The Value Chain Concept Please respond to the followingDescribe.docx
The Value Chain Concept Please respond to the followingDescribe.docxThe Value Chain Concept Please respond to the followingDescribe.docx
The Value Chain Concept Please respond to the followingDescribe.docx
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Maintains List of 4 Integers

  • 1. /** * This class maintains a list of 4 integers. * * This list is simple and unusual in it always contains exactly the * same number of elements. Later, when we know more Java, we will * study classes where the number of elements may vary. * * In this version 2, we use variables in the subscripts. * * @author Raymond Lister * @version August 2014 * */ public class ListOf4V2PartA { private static final int listSize = 4; private int[] list = {0, 1, 2, 3}; /** * A constructor for objects of class ListOf4, which takes four parameters * * @param one an initial element for the list, the first element. * @param two an initial element for the list * @param three an initial element for the list * @param four an initial element for the list, the last element. */ public returnTypeIfAny nameOfConstructor(int one, int two, int three, int four) { add whatever code is required to this constructor body to initialize the four elements of array "list" to
  • 2. the values given in the parameters. } // constructor ListOf4(int one, int two, int three, int four) /** * @return the number of elements stored in this list */ public returntype getListSize(parametersIfAny) { return something; } // method getListSize /** * @return the last element in the list */ public returntype getLast(parametersIfAny) { add whatever code is required here in the method body } // method getLast /** * prints the contents of the list, in order from first to last */ public returntype printList(para metersIfAny) { // with variable subscripts ... System.out.print("{"); int i = initial value; // role: stepper System.out.print(list[array subscript]); i = updated value; System.out.print(", " + list[array subscript]); copy and paste some of the code above, as many times as
  • 3. required System.out.print("}"); } // method printList /** * prints the contents of the list, in order from first to last, and * then moves the cursor to the next line */ public void printlnList() { printList(); System.out.println(); } // method printlnList /** * @return the number of times the element occurs in the list * * @param element the element to be counted */ public returntype countElement(parametersIfAny) { int count = 0; // role: stepper // with variable subscripts ... int i = initial; // role: stepper if ( list[subscript] == something ) doSomething; i = updatedVal; copy and paste some of the code above, as many times as required return returnValue;
  • 4. } // method countElement /** * @return the number of times the replacement was made * * @param replaceThis the element to be replaced * @param withThis the replacement */ public returntype replaceAll(parametersIfAny) { int count = 0; // role: stepper; number of replacements made // with variable subscripts ... int i = beginning value; // role: stepper if ( list[sub] == something ) { list[sub] = something; increment something; } increment something; copy and paste some of the code above, as many times as required return count; } // method replaceAll /** * @return the first position in list occupied by the parameter value, or -1 if it is not found * * @param findThis the value to be found */
  • 5. public returntype findUnSorted(parametersIfAny) { // This algorithm is known as "linear search" // with variable subscripts ... int pos = initialValueForPos; if ( list[subscript] == something ) return whatever; pos = updatedVal; copy and paste some of the code above, as many times as required return notFound; } // method findUnSorted /** * @return the position of the smallest element in the array */ public returntype minPos(parametersIfAny) { int mostWantedHolder = initial value; // role: Most-wanted holder // variable mostWantedHolder remembers the position of the // smallest number seen so far // with variable subscripts ... int i = initial value; // role: stepper if ( list[subscript1] < list[subscript2] ) { update mostWantedHolder } i = newVal;
  • 6. copy and paste some of the code above, as many times as required return theAppropriateValue; } // method minPos /** * 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 */ public void swap(int i, int j) { int temp; // role: temporary temp = list[i]; list[i] = list[j]; list[j] = temp; } // method swap /** * Orders the elements of the list, with the first element smallest and the * last element largest. Does this using the bubblesort algorithm. */ public returntype sortBubble(parametersIfAny) { /* This implementation uses the bubble sort algorithm. For an explanation * of how bubblesort works, google ... * bubblesort java
  • 7. */ // with variable subscripts ... int i = initialize i; // role: stepper if ( list[subscript1] > list[subscript2] ) swap(subscript3, subscript4); i = nextVal; copy and paste some of the code above, as many times as required // At this point, the largest element must be in list[3]. reinitialize i copy and paste some of the code above, as many times as required // At this point, the second largest element must be in list[2]. reinitialize i copy and paste some of the code above, as many times as required // At this point, the smallest element must be in list[0]. } // method sortBubble } // class ListOf4V2 Solution /**
  • 8. * * This class maintains a list of 4 integers. * * This list is simple and unusual in it always contains exactly the same number * of elements. Later, when we know more Java, we will study classes where the * number of elements may vary. * * In this version 2, we use variables in the subscripts. * * @author Raymond Lister * @version August 2014 * */ public class ListOf4V2PartA { private static final int listSize = 4; private int[] list = { 0, 1, 2, 3 }; /** * A constructor for objects of class ListOf4, which takes four parameters * * @param one * an initial element for the list, the first element. * @param two
  • 9. * an initial element for the list * @param three * an initial element for the list * @param four * an initial element for the list, the last element. */ public ListOf4V2PartA(int one, int two, int three, int four) { list[0] = one; list[1] = two; list[2] = three; list[3] = four; } // constructor ListOf4(int one, int two, int three, int four) /** * @return the number of elements stored in this list */ public int getListSize() { return list.length; } // method getListSize /** * @return the last element in the list */ public int getLast() { // add whatever code is required here in the method body return list[list.length - 1]; } // method getLast
  • 10. /** * prints the contents of the list, in order from first to last */ public void printList() { // with variable subscripts ... System.out.print("{"); for (int i = 0; i < list.length; i++) { if (i == 0) System.out.print(list[i]); else System.out.print(", " + list[i]); } System.out.print("}"); } // method printList /** * prints the contents of the list, in order from first to last, and then * moves the cursor to the next line */ public void printlnList() { printList(); System.out.println(); } // method printlnList /** * @return the number of times the element occurs in the list
  • 11. * * @param element * the element to be counted */ public int countElement(int element) { int count = 0; // role: stepper // with variable subscripts ... for (int i = 0; i < list.length; i++) { if (list[i] == element) count++; } return count; } // method countElement /** * @return the number of times the replacement was made * * @param replaceThis * the element to be replaced * @param withThis * the replacement */ public int replaceAll(int replaceThis, int withThis) { int count = 0; // role: stepper; number of replacements made // with variable subscripts ...
  • 12. for (int i = 0; i < list.length; i++) { if (list[i] == replaceThis) { list[i] = withThis; count++; } } return count; } // method replaceAll /** * @return the first position in list occupied by the parameter value, or -1 * if it is not found * * @param findThis * the value to be found */ public int findUnSorted(int findThis) { // This algorithm is known as "linear search" // with variable subscripts ... int pos = -1; for (int i = 0; i < list.length; i++) { if (list[i] == findThis) return i; } return pos;
  • 13. } // method findUnSorted /** * @return the position of the smallest element in the array */ public int minPos() { int mostWantedHolder = list[0]; // role: Most-wanted holder // variable mostWantedHolder remembers the position of the // smallest number seen so far int pos = 0; // with variable subscripts ... for (int i = 0; i < list.length; i++) { if (list[i] < mostWantedHolder) { mostWantedHolder = list[i]; pos = i; } } return pos; } // method minPos /** * Swaps two elements in the list * * @param i * the position of one of the elements to be swapped
  • 14. * @param j * the position of one of the elements to be swapped */ public void swap(int i, int j) { int temp; // role: temporary temp = list[i]; list[i] = list[j]; list[j] = temp; } /** * Orders the elements of the list, with the first element smallest and the * last element largest. Does this using the bubblesort algorithm. */ public void sortBubble() { /* * This implementation uses the bubble sort algorithm. For an * explanation of how bubblesort works, google ... bubblesort java */ for (int i = (list.length - 1); i >= 0; i--) { for (int j = 1; j <= i; j++) { if (list[j - 1] > list[j]) {
  • 15. int temp = list[j - 1]; list[j - 1] = list[j]; list[j] = temp; } } } // At this point, the smallest element must be in list[0]. } // method sortBubble } // class ListOf4V2 /** * @author * */ public class TestListOf4V2PartA { /** * @param args */ public static void main(String[] args) { ListOf4V2PartA listOf4V2PartA = new ListOf4V2PartA(5, 15, 4, 13); System.out.println("getListSize()-->" + listOf4V2PartA.getListSize()); System.out.println("getLast()-->" + listOf4V2PartA.getLast()); listOf4V2PartA.printList();
  • 16. listOf4V2PartA.printlnList(); System.out.println("countElement()-->" + listOf4V2PartA.countElement(15)); System.out.println("replaceAll()-->" + listOf4V2PartA.replaceAll(13, 14)); System.out.println("findUnSorted()-->" + listOf4V2PartA.findUnSorted(13)); System.out.println("minPos()-->" + listOf4V2PartA.minPos()); System.out.println("After swap 1 and 2:"); listOf4V2PartA.swap(1, 2); listOf4V2PartA.printlnList(); System.out.println("After sorting : "); listOf4V2PartA.sortBubble(); listOf4V2PartA.printList(); } } OUTPUT: getListSize()-->4 getLast()-->13 {5, 15, 4, 13}{5, 15, 4, 13} countElement()-->1 replaceAll()-->1 findUnSorted()-->-1
  • 17. minPos()-->2 After swap 1 and 2: {5, 4, 15, 14} After sorting : {4, 5, 14, 15}