Question: JAVA Midterm.java /* Please complete the programming questions here and submit the file on Canvas */ /* WRITE YOUR NAME HERE */ import java.util.*; public
JAVA

Midterm.java
/* Please complete the programming questions here and submit the file on Canvas */ /* WRITE YOUR NAME HERE */
import java.util.*;
public class Midterm1 { /* The main is to test your implementations. Examples in the questions are implemented in main. * Do not change anything in main */ public static void main (String [] args) { ArrayList
Map
this is for practice
Download the main method file here: Midterm.java Open the file and add your code for method1 - method3 (Q1-Q3 below) When you are done, upload the file. The file name should NOT be changed : Midterm.java Here is the expected output when the completed program is executed: Q1: [3, 4, 5] [3, 4, 5), Q1: [] [] Q2: [key1, key3] Q3: Correct Q1. Write a method called method 1 that takes an integer n and an ArrayList of integers as parameters and deletes all elements less than n in the ArrayList. For example, if a variable called list stores the vaules (1,2,3,4,5), method1 (3, list) should delete all values less than 3, changing the list to store (3, 4, 5). If a call method1 ( 6, list ) is made again on the list = [3,4,5), the list will be [] after the call since all values less than 6 will be removed from the list. Q2. Write a method called method2 that accepts a map as a parameter. The keys are strings and values are string arrays. method2 will return the set containing keys with 3 values from the map. The returned set should be sorted in an ascending order. For example, the map {key1=[value1, value2, value3), key2=[value4, value5, value6, value7], key3=[value8, value9, value10] will return [key1, key3]. Q3: Write a recursive method called method3 that accepts an integer parameter and returns the integer reformed by repeating digits 1 and 2. For example, method3 (123456) will return 11223456 repeating only 1 and 2 and method3 (21) will return 2211. If the number is 0, return 0. You may assume that n is not negative. Loop structures should not be used. Download the main method file here: Midterm.java Open the file and add your code for method1 - method3 (Q1-Q3 below) When you are done, upload the file. The file name should NOT be changed : Midterm.java Here is the expected output when the completed program is executed: Q1: [3, 4, 5] [3, 4, 5), Q1: [] [] Q2: [key1, key3] Q3: Correct Q1. Write a method called method 1 that takes an integer n and an ArrayList of integers as parameters and deletes all elements less than n in the ArrayList. For example, if a variable called list stores the vaules (1,2,3,4,5), method1 (3, list) should delete all values less than 3, changing the list to store (3, 4, 5). If a call method1 ( 6, list ) is made again on the list = [3,4,5), the list will be [] after the call since all values less than 6 will be removed from the list. Q2. Write a method called method2 that accepts a map as a parameter. The keys are strings and values are string arrays. method2 will return the set containing keys with 3 values from the map. The returned set should be sorted in an ascending order. For example, the map {key1=[value1, value2, value3), key2=[value4, value5, value6, value7], key3=[value8, value9, value10] will return [key1, key3]. Q3: Write a recursive method called method3 that accepts an integer parameter and returns the integer reformed by repeating digits 1 and 2. For example, method3 (123456) will return 11223456 repeating only 1 and 2 and method3 (21) will return 2211. If the number is 0, return 0. You may assume that n is not negative. Loop structures should not be used
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
