Question: Declare variable widthList as a LinkedList of type Integer. Read integer numIterations from input. For numIterations iterations, insert integers 2 4 and 4 9 into

Declare variable widthList as a LinkedList of type Integer. Read integer numIterations from input. For numIterations iterations, insert integers 24 and 49 into widthList, in that order.
Ex: If the input is 6, then the output is:
244924492449244924492449
import java.util.Scanner;
import java.util.LinkedList;
public class MakeWidthList {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
int numIterations;
int i;
/* Variable declarations go here */
/* Your code goes here */
// Traversing a list using indexes
for (i =0; i < widthList.size(); ++i){
System.out.print(widthList.get(i)+"");
}
System.out.println();
}
}

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!