Question: For intro to java problem 10.6, cant figure out why the error Im getting is there or how to fix it 111/** 13 141 public

For intro to java problem 10.6, cant figure out why the error Im getting is there or how to fix it  For intro to java problem 10.6, cant figure out why the
error Im getting is there or how to fix it 111/** 13
141 public class Stack0fIntegers { 16 17 * eparan args the command

111/** 13 141 public class Stack0fIntegers { 16 17 * eparan args the command line arguments 19 public static void main(Stringt) args) ( II TODO code application logic here 21 //Problem 10.6 Display The Prime Numbers I1 Create a StackofIntegers StackfIntegers stack- new StackofIntegers) /1 Find and push all prime numbers less than 120 to stack for (int i 211 120; 1+) if (isPrise(1)) stack.push()i 31 // Displays all the prine numbers less than 120 in decreasing o System.out.printLn while (Istack.enpty)) System.out.println): "InAll the prime numbers less than 128 in decreasing order:" System.out.print(stack.pop() +) / Return true if n is a prine number public static lisPrine(11) { for (int d 2id n2; d++) 45 return false 47 return true; 1 Next -Select,aA" Previous 20 2 3 4 5 6 Start Page x Stackon MyRectangle2DJava x 51 52 private intll elements: private int size public static final int DEFAULT CAPACITY16 *Construct a stack with the default capacity 16 / public StackofIntegers) this (DEFAULT CAPACITY) 57 / Construct a stack with the specified maximum capacity / public StackofIntegers (Int cepacit) 61 elements new inticapacityli * Push a new integer to the top of the stack * public void push(ntau) 641 if (size elements. length) f intu temp = new int [elements. length * 2); System.arraycopy(elements, e, temp, , elements. Length) elements # teep; elements(size++] . value; 73 /s* Return and remove the top element from the stack / public Int pop) t return elements [--size]: /ss Return the top elenent from the stack/ public int peek) return elements[size 11 85 0 Test whether the stack is empty * public soonaan empty() { 0; return size Previous -Next -Select aA -" .* 2 3 4 5 6 731L x Return and remove the top element from the stack / public Int popt) t return elements[-sizel: 78 79 /e* Return the top element from the stack / return elements[size 1]: public peek(){ 84 /e* Test whether the stack is empty / public booempty) ( 2 87 return size 0; /* Return the number of elements in the stack/ public getSize() { return size 9 } -Next -Select iaA.-.. Previous 2.0 888 FA 15 2 3 4 6

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!