Can you help with my code? I am attaching the errors I am receiving. But this is what the expected output for the program should be: Reading record 0: m3us1 m2ck15 Reading record 1: fl2ntst3n1 fr1d...


Can you help with my code? I am attaching the errors I am receiving.


But this is what the expected output for the program should be:
Reading record 0: m3us1 m2ck15
Reading record 1: fl2ntst3n1 fr1d
Reading record 2: s2mps3n h3m1r
Reading record 3: d31 j3hn
Reading record 4: l2ghty10r b4zz
Reading record 5: j31l b2ll5
Reading record 6: br3wn ch0rl21
Reading record 7: br0v3 j3hnn5
Reading record 8: b2rd tw11ty
Reading record 9: h1dg1h3g s3n2c
Reading record 10: j1ts3n g13rg1
Reading record 11: m0rt20n m0rv2n
Modified records:
Record 0: mouse mickey
Record 1: flintstone fred
Record 2: simpson homer
Record 3: doe john
Record 4: lightyear buzz
Record 5: joel billy
Record 6: brown charlie
Record 7: bravo johnny
Record 8: bird tweety
Record 9: hedgehog sonic
Record 10: jetson george
Record 11: martian marvin





JAVA CODE:



import java.io.File;
import java.io.FileNotFoundException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Random;
import java.util.Scanner;


public class PA3 {


String newName;


static String modifyName = "";


static String bigRecord;


static String[] bigRecordArray = new String[20];


static int index = 0;


static int aNumber;


public static void main(String[] args) {


Random rand = new Random();


List list = new LinkedList();


Path file = Paths.get("info2.txt");


Scanner sc = null;


try {


sc = new Scanner(new File(file.getFileName().toString()));


System.out.println("Information Read form file:");


while (sc.hasNext()) {


bigRecord = sc.nextLine();


System.out.println("Reading Record " + index + ": " + bigRecord);


bigRecordArray[index++] = modifyVowels(bigRecord, modifyName);


}


sc.close();


} catch (FileNotFoundException e) {


e.printStackTrace();


}


System.out.println("Modified Records:");


printRecords(bigRecordArray, index - 1);


bubbleSort(bigRecordArray, index - 1);


createLinkedList(list, bigRecordArray, index);


printList(list);


aNumber = rand.nextInt(index);


System.out.println("\nWill be removing record number: " + aNumber);
list.remove(aNumber);


printList(list);


aNumber = rand.nextInt(index);
System.out.println("\nWill be removing record number: " + aNumber);


list.remove(aNumber);


printList(list);
}


public static String modifyVowels(String fullName, String modifyName) {


if (fullName.length() == 0)


return modifyName;


else {


if (fullName.charAt(0) == '0')


modifyName = modifyName + "a";


else if (fullName.charAt(0) == '1')


modifyName = modifyName + "e";


else if (fullName.charAt(0) == '2')


modifyName = modifyName + "i";


else if (fullName.charAt(0) == '3')


modifyName = modifyName + "o";


else if (fullName.charAt(0) == '4')


modifyName = modifyName + "u";


else if (fullName.charAt(0) == '5')


modifyName = modifyName + "y";


else


modifyName = modifyName + fullName.charAt(0);


return modifyVowels(fullName.substring(1), modifyName);


}


}


public static void printRecords(String[] fullName, int index) {


for (int i = 0; i <= index;="" i++)="">


System.out.println("Record " + i + ": " + fullName[i]);


}


}


static void bubbleSort(String[] arr, int n) {


String temp = "";


for (int j = 0; j < n;="">


{


for (int i = j + 1; i < n="" +="" 1;="">


{


if (arr[j].compareTo(arr[i]) > 0)


{


temp = arr[j];


arr[j] = arr[i];


arr[i] = temp;


}


}


}


System.out.println("After Sorting:");


printRecords(arr, n);


}


static void createLinkedList(List list, String[] fullName, int index) {


for (int i = 0; i < index;="" i++)="">
list.add(fullName[i]);
}
}


static void printList(List list) {


System.out.println("\nLinked list records:");
int i = 0;
ListIterator iterator = list.listIterator();
while (iterator.hasNext())
System.out.println("Record " + i++ + ": " + iterator.next());
}
}



File Edit Tools Project Language Level Help<br>LA New<br>a Open<br>L Close<br>% Cut<br>O Copy<br>A Find<br>Save<br>Paste<br>Undo<br>Redo<br>Compile<br>Reset<br>160<br>}<br>PA3.java<br>161<br>162<br>163<br>System.out.println (

Extracted text: File Edit Tools Project Language Level Help LA New a Open L Close % Cut O Copy A Find Save Paste Undo Redo Compile Reset 160 } PA3.java 161 162 163 System.out.println ("After Sorting: "); 164 165 printRecords (arr, n); 166 167 Interactions Console Compiler Output at sun.reflect. NativeMethodAccessor Impl.invoke (Unknown Source) at sun.reflect. DelegatingMethodAccessor Impl.invoke (Unknown Source) at java.lang.reflect.Method. invoke (Unknown Source) at sun.rmi.server. UnicastServerRef.dispatch (Unknown Source) at sun.rmi.transport. Transport$1.run (Unknown Source) at sun.rmi. transport. Transport$1.run (Unknown Source) at java.security. AccessController.doPrivileged (Native Method) at sun.rmi.transport. Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp. TCPTransport.handleMessages (Unknown Source) at sun.rmi. transport.tcp. TCPTransport$ConnectionHandler.run0 (Unknown Source) at sun.rmi.transport.tcp. TCPTransport$ConnectionHandler.lambdaşrun$0 (Unknown Source) at java.security.AccessController.doPrivileged (Native Method) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run (Unknown Source) at java.util.concurrent. ThreadPoolExecutor.runWorker (Unknown Source) at java.util.concurrent. ThreadPoolExecutor $Worker.run (Unknown Source) at java.lang. Thread.run (Unknown Source) Modified Records: After Sorting: Linked list records: java.lang. IllegalArgumentException: bound must be positive at java.util. Random.next Int (Unknown Source) at PA3.main (PA3.java:69) at sun.reflect.NativeMethodAccessor Impl. invoke0 (Native Method) at sun.reflect.NativeMethodAccessor Impl.invoke (Unknown Source) at sun.reflect.DelegatingMethodAccessor Impl.invoke (Unknown Source) at java.lang.reflect.Method. invoke (Unknown Source) at edu.rice.cs.drjava.model.compiler.JavacCompiler.runcommand (JavacCompiler.java:272)

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here