(Please Try and Provide me a complete programm Answer. not just one or two funct
ID: 3792254 • Letter: #
Question
(Please Try and Provide me a complete programm Answer. not just one or two function)
* Declare a single dimensional array of 65 characters. Convert each character into an integer and store it in a linked list. Manipulate the linked list by completing the following task:
Create an additional linked list call greater_List, using the original linked list copy all number greater than 100 into the greater_list and give a total count of the numbers greater than 100. Create an additional array called less_array, copy all the numbers less than or equal to 100 in the original list into less_array give a total count of the numbers that are less than or equal to 100.
Explanation / Answer
import java.util.ArrayList;
import java.util.LinkedList;
public class LinkedListTest {
public static void main(String[] args) {
char[] input = new char[65];
int temp=0;
int count=0, i=0;
LinkedList<Integer> list = new LinkedList<Integer>();
for(i=0;i<input.length;i++){
temp = Integer.parseInt(String.valueOf(input[i]));
list.add(i, temp);
}
LinkedList<Integer> greater_list = new LinkedList<Integer>();
for(i=0;i<list.size();i++){
if(list.get(i).intValue() > 100){
greater_list.add(i, list.get(i).intValue());
count++;
}
}
System.out.println("Count of values in greater_list: "+ count);
count=0;
ArrayList<Integer> less_array = new ArrayList<Integer>();
for(i=0;i<list.size();i++){
if(list.get(i).intValue() <= 100){
less_array.add(list.get(i).intValue());
count++;
}
}
System.out.println("Count of values in less_array: "+ count);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.