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

Need help with a Java problem: Copy the code provided below called Finish . This

ID: 3831451 • Letter: N

Question

Need help with a Java problem:

Copy the code provided below called Finish. This contains only a main method. You are to add your methods to that program class. When you compile and run it, the main method will call each of the methods you are writing in response to the problems below.

Finish.java:

import java.util.ArrayList;
import java.util.Arrays;
import algs13.Stack;
import stdlib.*;

public class Midterm {

   // Your methods go here.

   public static void main(String[] args) {
       StdOut.println(floorlog(32));
       StdOut.println(floorlog(35));
       StdOut.println(floorlog(64));
       StdOut.println(floorlog(2048));

       Double[] sqarray = {3.5, 4.7, 10.1, 25.0, 76.34, 100.01, 256.0};
       ArrayList<Double> dlist = new ArrayList<Double>(Arrays.asList(sqarray));
       StdOut.println(dlist);
       squareRootList(dlist);
       StdOut.println(dlist);

       StdOut.println(falling(10, 2));
       StdOut.println(falling(52, 6));

       dlist = new ArrayList<Double>();
       StdOut.println(sumBelowLimit(dlist, 50.0));
       Double[] sbarray = {45.3, 12.4, 50.1, 32.8, 75.5, 49.9, 50.0};
       dlist = new ArrayList<Double>(Arrays.asList(sbarray));
       StdOut.println(sumBelowLimit(dlist, 50.0));

       ArrayList<Integer> ilist = new ArrayList<Integer>();
       StdOut.println(productOfEvens(ilist));

       Integer[] eparray1 = {2, 3, 4, 9, 11, 12};
       ilist = new ArrayList<Integer>(Arrays.asList(eparray1));
       StdOut.println(productOfEvens(ilist));

       Integer[] eparray2 = {7, 3, 53, 9, 11, 19};
       ilist = new ArrayList<Integer>(Arrays.asList(eparray2));
       StdOut.println(productOfEvens(ilist));

       String[] starray = {"hello", "how", "are", "you"};
       reverse(starray);
       StdOut.println(Arrays.toString(starray));
   }
}

Problem floorlog (8 points0 Write a static method called floorlog that takes a single int parametern. It should contain a while loop that keeps dividing n by 2 until its value is less than or equal to 1 and that also uses a counter to count how many iterations the loop takes. It should then return that counter. Problem squareRootList (8 points) Write a static method called squareRootList that takes an array list of Double values. It then replaces each value in that array list with its square root. For example, if the array list contained the values 1.0, 2.0, 3.0, 4.0 before calling the method, after returning from the method it should contain the values 1.0, 1.4142 135623730951, 1.7320508075688772, 2.0. Problem falling (9 points) Write a recursive public static method to calculate the falling power function. It has the signature: public static long falling (long n, long e) As you can see, it takes two long parameters n and e. Here is the mathematical definition: In the expressions above, the notation ne is read "n to the falling power e Problem sumBelowLimit (8 points) Write a public static method sumBelowLimit that, given as parameters an array listof Doubles and a double value called a limit, returns the sumof the values in the list that are less than the limit. Problem productofEvens (8 points) Write a public static method productofEvens to compute the product of the even numbers in an array list of Integers given as a parameter. B definition, the product of an empty list of numbers is 1. Problem reverse (9 points) Write a public static method reverse that takes as a parameter an array of strings and, using a stack, reverses the order of the strings in the array.

Explanation / Answer

//Problem floorlog:

public class getFloorLog {

   public static void main(String[] args)

   {

       System.out.println(floorlog(10));

   }

   private static int floorlog(int i) {

       // TODO Auto-generated method stub

       int count=0;

       while(i>1)

       {

           i=i/2;

           count++;

       }

       return count;

   }

}

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