eading 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 bu

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

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<String> list = new LinkedList<String>();

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; j++)

{

for (int i = j + 1; i < n + 1; i++)

{

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<String> list, String[] fullName, int index) {

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

static void printList(List<String> list) {

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

 

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)
Transcribed Image 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)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education