Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help filling in the areas, unsure of how to do the code, JAVA. I\'ve highli

ID: 3728404 • Letter: N

Question

 Need help filling in the areas, unsure of how to do the code, JAVA. I've highlited what needs completing. 
 import java.util.Stack ; /**     Practices using the Stack from the Java API.  */ public class StackApiTester {     public static void main(String[] args)     {         Stack<String> stack = new Stack<String>() ;         stack.push("horse") ;         stack.push("cat") ;         stack.push("dog") ;         stack.push("cow") ;         stack.push("mouse") ;         System.out.println(stack.pop()) ;         System.out.println(stack.pop()) ;         System.out.println(stack.pop()) ;         System.out.println(stack.peek()) ;         System.out.println("stack is empty? " + stack.isEmpty()) ;         System.out.println(stack.pop()) ;         System.out.println("stack is empty? " + stack.isEmpty()) ;         System.out.println(stack.pop()) ;         System.out.println("stack is empty? " + stack.isEmpty()) ;         //-----------Start below here. To do: approximate lines of code = 8         // 1. make a stack that holds integers ;                   //2. push in the integers from 1 to 100 that are divisible by 3 ;                                     //3. print the size ;                   //4. while stack not empty ;                       //5. let value hold pop ;                       //6. if value divisible by 9 then print it.                                    //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.     } } 

Explanation / Answer

import java.util.Stack ; /** Practices using the Stack from the Java API. */ public class StackApiTester { public static void main(String[] args) { Stack stack = new Stack() ; stack.push("horse") ; stack.push("cat") ; stack.push("dog") ; stack.push("cow") ; stack.push("mouse") ; System.out.println(stack.pop()) ; System.out.println(stack.pop()) ; System.out.println(stack.pop()) ; System.out.println(stack.peek()) ; System.out.println("stack is empty? " + stack.isEmpty()) ; System.out.println(stack.pop()) ; System.out.println("stack is empty? " + stack.isEmpty()) ; System.out.println(stack.pop()) ; System.out.println("stack is empty? " + stack.isEmpty()) ; //-----------Start below here. To do: approximate lines of code = 8 // 1. make a stack that holds integers ; Stack stack1 = new Stack(); //2. push in the integers from 1 to 100 that are divisible by 3 ; for (int i = 1; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote