Question: 1 1 . 1 0 ArrayList practice Practice creating an ArrayList and some of its functions Import the appropriate packages to use the ArrayList and

11.10 ArrayList practice
Practice creating an ArrayList and some of its functions
Import the appropriate packages to use the ArrayList and Scanner classes
In the main() method
Use the given code to begin writing your program
Write the code to get four integer values from the user and put them in the rateList. Use a loop.
Prompt user for a number to add and add it to the rateList
Prompt user for a number to check
Write the code for the first containsValue() method to allow the lines of code to execute and show results
Prompt user for a number and index to check
Write the code for the second containsValue() method to allow the lines of code to execute and show results
Create a method containsValue() that takes two parameters: an ArrayList of integers and an integer value
Use an arraylist method to check if the value passed as an argument is in the list
For instance, with an input of 3, if the number is in the list, display the following output:
The number 3 is in the list
If the number is not in the list, display the following output:
The number 3 is not in the list
Overload the method containsValue() to include three parameters: an ArrayList of integers, an integer for a value, and an integer for an index
Check if the value is located in the given index location
For instance, with an input of 80 and index 3, if the value in index 3 is 80, display the following output:
The number 80 is at index 3
If the value at index 3 is not 80, display
The number 80 is not at index 3
Display if the number 80 is in another index, or not in the list at all
The number 80 is at index 2
or
The number 80 is not in the list
JAVA PLEASE
USE THIS CODE
// imports
//** add your code here **
public class ArrayListExample {
public static void main(String[] args){
// Variables - these should be enough, but you may add additional variables if you need to
Scanner scnr = new Scanner(System.in);
int number, index;
ArrayList rateList = new ArrayList();
// get values from user and put them in the rateList
System.out.println("Enter four integer values: ");
//** add your code here **
System.out.println("List values: "+ rateList);
// get number from user
//** add your code here **
//add number to the arrayList
//** add your code here **
System.out.println("List values: "+ rateList);
// check if value added is in the list
System.out.print("Enter a number to check: ");
//** add your code here **
// get value and index from user
//** add your code here **
// add number at index value
//** add your code here **
System.out.println("List values: "+ rateList);
// get value and index from user to check
//** add your code here **
// check if value exists at specific index location
//** add your code here **
}
/**
* Checks if the value is contained in the rateList
* Displays an appropriate message to indicate if the value is in, or is not in the list
*
* @param rateList
* @param value
*/
public static void containsValue(** add your code for parameters here **){
//** add your code here **
}
/**
* Checks if the value is contained in the rateList at the index location
* Displays an appropriate message to indicate if the value is in the location,
* if it is in the list but in another location, or is not in the list
*
* @param rateList
* @param value
* @param index
*/
public static void containsValue(** add your code for parameters here **){
//** add your code here **
}
}
}

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 Programming Questions!