Questions by okey43 - Page 36

Correct my codeimport java.util.*;import java.io.*;public class PhotoLineups{public static void main(String[] args){int in=0;Scanner sc= new Scanner(System.in);ArrayList al = new ArrayList();boolean con =true;while(con){String s= sc.next();if(!s.equals("-1"))al.add(s);elsecon=false;}allPermutations(al, 0);}private static void allPermutations(ArrayList arr, int index){if(index >= arr.size() - 1){for(int i = 0; i < arr.size() - 1; i++){System.out.print(arr.get(i) + " ");}if(arr.size() > 0)System.out.print(arr.get(arr.size() - 1));System.out.print(" \n");return;}for(int i = index; i < arr.size(); i++){Collections.swap(arr, index, i);allPermutations(arr, index+1);Collections.swap(arr, index, i);All permutations of names Write a program that lists all ways people can line up for a photo (all permutations of a list of Strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia Compiler warnings PhotoLineups.java:9: warning: [rawtypes] found raw type: ArrayList ArrayList al = new ArrayList(); missing type arguments for generic class ArrayList where E is a type-variable: E extends Object declared in class ArrayList PhotoLineups.java:9: warning: [rawtypes) found raw type: ArrayList ArrayList al = new ArrayList(); missing type arguments for generic class ArrayList where Eis a type-variable: E extends Object declared in class ArrayList PhotoLineups.java:15: warning: [unchecked] unchecked call to add (E) as a member of the raw t al.add(s); where E is a type-variable: E extends Object declared in class ArrayList PhotoLineups.java:22: warning: [rawtypes] found raw type: ArrayList private static void allPermutations (ArrayList arr, int index) { missing type arguments for generic class ArrayList where E is a type-variable: E extends Object declared in class ArrayList 4 warnings 1: Compare output 0/1 Output differs. See highlights below. Input Julia Lucas Mia - 1 Your output Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Lucas Julia Mia Julia Lucas Expected output Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia 3: Compare output Output differs. See highlights below. Input Chloe Mila Kellan -1 Your output Chloe Mila Kellan Chloe Kellan Mila Mila Chloe Kellan Mila Kellan Chloe Kellan Mila Chloe Kellan Chloe Mila Expected output Chloe Mila Kellan Chloe Kellan Mila Mila Chloe Kellan Mila Kellan Chloe Kellan Chloe Mila Kellan Mila Chloe 4: Compare output Output differs. See highlights below. Special character legend Input Mila Chloe Kellan Keri -1 Your output Mila Chloe Kellan Keri Mila Chloe Keri Kellan Mila Kellan Chloe Keri Mila Kellan Keri Chloe Mila Keri Kellan Chloe Mila Keri Chloe Kellan Chloe Mila Kellan Keri Chloe Mila Keri Kellan Chloe Kellan Mila Keri Chloe Kellan Keri Mila Chloe Keri Kellan Mila Chloe Keri Mila Kellan Kellan Chloe Mila Keri Kellan Chloe Keri Mila Kellan Mila Chloe Keri Kellan Mila Keri Chloe Kellan Keri Mila Chloe Kellan Keri Chloe Mila Keri Chloe Kellan Mila Keri Chloe Mila Kellan Keri Kellan Chloe Mila Keri Kellan Mila Chloe Keri Mila Kellan Chloed Keri Mila Chloe Kellan Your output Mila Chloe Kellan Keri Mila Chloe Keri Kellan Mila Kellan Chloe Keri Mila Kellan Keri Chloe Mila Keri Kellan Chloe Mila Keri Chloe Kellan Chloe Mila Kellan Keri Chloe Mila Keri Kellan Chloe Kellan Mila Keri Chloe Kellan Keri Mila Chloe Keri Kelian Mila Chloe Keri Mila Kellan Kellan Chloe Mila Keri Kellan Chloe Keri Mila Kellan Mila Chloe Keri Kellan Mila Keri Chloe Kellan Keri Mila Chloe Kellan Keri Chloe Mila Keri Chloe Kellan Mila Keri Chloe Mila Kellan Keri Kellan Chloe Mila Keri Kellan Mila Chloe Keri Mila Kellan Chloe Keri Mila Chloe Kellan Expected output Mila Chloe Kellan Keri Mila Chloe Keri Kellan Mila Kellan Chloe Keri Mila Kellan Keri Chloe Mila Keri Chloe Kellan Mila Keri Kellan Chloe Chloe Mila Kellan Keri Chloe Mila Keri Kellan Chloe Kellan Mila Keri Chloe Kellan Keri Mila Chloe Keri Mila Kellan Chloe Keri Kellan Mila Kellan Mila Chloe Keri Kellan Mila Keri Chloe Kellan Chloe Mila Keri Kellan Chloe Keri Mila Kellan Keri Mila Chloe Kellan Keri Chloe Mila Keri Mila Chloe Kellan Keri Mila Kellan Chloe Keri Chloe Mila Kellan Keri Chioe Kellan Mila Keri Kellan Mila Chloe Keri Kellan Chloe Mila Tests student Photos.allPermutations() correctly creates and outputs permutations Compilation failed zyLabs UnitTest.java:27: error: incompatible types: ArrayList cai student Photos.allPermutations (permist, namelist); Compilation failed Note: Some messages have been simplified; recompile with -Xdiags:verbos 1 error