|
001 packagepackage is used to name the directory or folder a class is in jam;
002
003 importimport means to make the classes and/or packages available in this program wiki.Wiki;
004 importimport means to make the classes and/or packages available in this program java.util.*;
005 /**
006 * All about my application here.
007 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
008 */
009 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects CountOnIt
010 {open braces start code blocks and must be matched with a close brace
011 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer count4s(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
012 {open braces start code blocks and must be matched with a close brace
013 intint is the type for whole numbers and it is short for integer count=this assignment operator makes the left side equal to the right side0;
014 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
015 {open braces start code blocks and must be matched with a close brace
016 ifif executes the next statement only if the condition in parenthesis evaluates to true(a==this is the comparison operator which evaluates to true if both sides are the same4)
017 count++this is the increment operator, which increases the variable by 1;
018 }close braces end code blocks and must match an earlier open brace
019 returnreturn means to provide the result of the method and/or cease execution of the method immediately count;
020 }close braces end code blocks and must match an earlier open brace
021
022 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer countAs(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
023 {open braces start code blocks and must be matched with a close brace
024 intint is the type for whole numbers and it is short for integer count=this assignment operator makes the left side equal to the right side0;
025 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
026 {open braces start code blocks and must be matched with a close brace
027 ifif executes the next statement only if the condition in parenthesis evaluates to true(a>89)
028 count++this is the increment operator, which increases the variable by 1;
029 }close braces end code blocks and must match an earlier open brace
030 returnreturn means to provide the result of the method and/or cease execution of the method immediately count;
031 }close braces end code blocks and must match an earlier open brace
032
033 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer getSum(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
034 {open braces start code blocks and must be matched with a close brace
035 intint is the type for whole numbers and it is short for integer sum=this assignment operator makes the left side equal to the right side0;
036 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
037 {open braces start code blocks and must be matched with a close brace
038 sum+=this increases the variable on the left by the value on the righta;
039 }close braces end code blocks and must match an earlier open brace
040 returnreturn means to provide the result of the method and/or cease execution of the method immediately sum;
041 }close braces end code blocks and must match an earlier open brace
042
043 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer getMax(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
044 {open braces start code blocks and must be matched with a close brace
045 intint is the type for whole numbers and it is short for integer max=this assignment operator makes the left side equal to the right sidenums[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
046 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
047 {open braces start code blocks and must be matched with a close brace
048 ifif executes the next statement only if the condition in parenthesis evaluates to true(a>max)
049 {open braces start code blocks and must be matched with a close brace
050 max=this assignment operator makes the left side equal to the right sidea;
051 }close braces end code blocks and must match an earlier open brace
052 }close braces end code blocks and must match an earlier open brace
053 returnreturn means to provide the result of the method and/or cease execution of the method immediately max;
054 }close braces end code blocks and must match an earlier open brace
055
056 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value swap(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums, intint is the type for whole numbers and it is short for integer indexA, intint is the type for whole numbers and it is short for integer indexB)
057 {open braces start code blocks and must be matched with a close brace
058 intint is the type for whole numbers and it is short for integer aux=this assignment operator makes the left side equal to the right sidenums[brackets are typically used to declare, initialize and index (indicate which element of) arraysindexA]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
059 nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysindexA]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenums[brackets are typically used to declare, initialize and index (indicate which element of) arraysindexB]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
060 nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysindexB]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sideaux;
061 }close braces end code blocks and must match an earlier open brace
062
063 publicpublic is used to indicate unrestricted access (any other class can have access) intint is the type for whole numbers and it is short for integer countOdds(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
064 {open braces start code blocks and must be matched with a close brace
065 intint is the type for whole numbers and it is short for integer count=this assignment operator makes the left side equal to the right side0;
066 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
067 {open braces start code blocks and must be matched with a close brace
068 ifif executes the next statement only if the condition in parenthesis evaluates to true(a%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same1)
069 count++this is the increment operator, which increases the variable by 1;
070 }close braces end code blocks and must match an earlier open brace
071 returnreturn means to provide the result of the method and/or cease execution of the method immediately count;
072 }close braces end code blocks and must match an earlier open brace
073
074 publicpublic is used to indicate unrestricted access (any other class can have access) booleanboolean is a type that is either true or false hasOdds(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
075 {open braces start code blocks and must be matched with a close brace
076 returnreturn means to provide the result of the method and/or cease execution of the method immediately countOdds(nums)>0;
077 //int count=0;
078 /*forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
079 {open braces start code blocks and must be matched with a close brace
080 ifif executes the next statement only if the condition in parenthesis evaluates to true(a%this divides the left side by the right side and evaluates to the remainder2==this is the comparison operator which evaluates to true if both sides are the same1)
081 returnreturn means to provide the result of the method and/or cease execution of the method immediately truetrue is the boolean value that is the opposite of false;
082 }close braces end code blocks and must match an earlier open brace
083 returnreturn means to provide the result of the method and/or cease execution of the method immediately falsefalse is a value for the boolean type and means not true;*/
084 //return count;
085 }close braces end code blocks and must match an earlier open brace
086
087 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value insertionSort(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
088 {open braces start code blocks and must be matched with a close brace
089 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<nums.length; i++this is the increment operator, which increases the variable by 1)
090 {open braces start code blocks and must be matched with a close brace
091 intint is the type for whole numbers and it is short for integer position=this assignment operator makes the left side equal to the right sidei;
092 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer j=this assignment operator makes the left side equal to the right sidei-1; j>=this evaluates to true if the left side is not less than the right side0; j--this is the decrement operator, which decreases the variable by 1)
093 {open braces start code blocks and must be matched with a close brace
094 ifif executes the next statement only if the condition in parenthesis evaluates to true(nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays<nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysj]brackets are typically used to declare, initialize and index (indicate which element of) arrays)
095 {open braces start code blocks and must be matched with a close brace
096 position=this assignment operator makes the left side equal to the right sidej;
097 }close braces end code blocks and must match an earlier open brace
098 }close braces end code blocks and must match an earlier open brace
099 intint is the type for whole numbers and it is short for integer aux=this assignment operator makes the left side equal to the right sidenums[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
100 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer k=this assignment operator makes the left side equal to the right sidei; k>position; k--this is the decrement operator, which decreases the variable by 1)
101 {open braces start code blocks and must be matched with a close brace
102 nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysk]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenums[brackets are typically used to declare, initialize and index (indicate which element of) arraysk-1]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
103 }close braces end code blocks and must match an earlier open brace
104 nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysposition]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sideaux;
105 }close braces end code blocks and must match an earlier open brace
106 }close braces end code blocks and must match an earlier open brace
107
108 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value selectionSort(intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums)
109 {open braces start code blocks and must be matched with a close brace
110 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer end=this assignment operator makes the left side equal to the right sidenums.length-1; end>0; end--this is the decrement operator, which decreases the variable by 1)
111 {open braces start code blocks and must be matched with a close brace
112 intint is the type for whole numbers and it is short for integer positionOfMax=this assignment operator makes the left side equal to the right side0;
113 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side1; i<=this evaluates to true if the left side is not more than the right sideend; i++this is the increment operator, which increases the variable by 1)
114 {open braces start code blocks and must be matched with a close brace
115 ifif executes the next statement only if the condition in parenthesis evaluates to true(nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays>=this evaluates to true if the left side is not less than the right sidenums[brackets are typically used to declare, initialize and index (indicate which element of) arrayspositionOfMax]brackets are typically used to declare, initialize and index (indicate which element of) arrays)
116 {open braces start code blocks and must be matched with a close brace
117 positionOfMax=this assignment operator makes the left side equal to the right sidei;
118 }close braces end code blocks and must match an earlier open brace
119 }close braces end code blocks and must match an earlier open brace
120 swap(nums, end, positionOfMax);
121 }close braces end code blocks and must match an earlier open brace
122 }close braces end code blocks and must match an earlier open brace
123
124 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
125 {open braces start code blocks and must be matched with a close brace
126 intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays nums=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor intint is the type for whole numbers and it is short for integer[brackets are typically used to declare, initialize and index (indicate which element of) arrays20]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
127 Random random=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Random();
128 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer i=this assignment operator makes the left side equal to the right side0; i<nums.length; i++this is the increment operator, which increases the variable by 1)
129 {open braces start code blocks and must be matched with a close brace
130 nums[brackets are typically used to declare, initialize and index (indicate which element of) arraysi]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right siderandom.nextInt(100);
131 }close braces end code blocks and must match an earlier open brace
132 CountOnIt count=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor CountOnIt();
133 Wiki.out.print("The values are:");
134 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
135 Wiki.out.print(" "+adds two numbers together or concatenates Strings togethera);
136 Wiki.out.println();
137 //Wiki.out.println("Swapping: "+nums[0]+" and "+nums[2]);
138 Wiki.out.println("sorting it out");
139 count.insertionSort(nums);
140 Wiki.out.print("The values are now:");
141 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer a: nums)
142 Wiki.out.print(" "+adds two numbers together or concatenates Strings togethera);
143 Wiki.out.println();
144 }close braces end code blocks and must match an earlier open brace
145 }close braces end code blocks and must match an earlier open brace
|