Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

m3us1 m2ck15 fl2ntst3n1 fr1d s2mps3n h3m1r d31 j3hn l2ghty10r b4zz j31l b2ll5 br3wn ch0rl21 br0v3 j3hnn5 b2rd tw11ty h1dg1h3g s3n2c j1ts3n g13rg1 m0rt20n m0rv2n Programming Assignment 3 Dr. CastaƱeda...

1 answer below Ā»
m3us1 m2ck15
fl2ntst3n1 fr1d
s2mps3n h3m1
d31 j3hn
l2ghty10r b4zz
j31l b2ll5
3wn ch0rl21
0v3 j3hnn5
2rd tw11ty
h1dg1h3g s3n2c
j1ts3n g13rg1
m0rt20n m0rv2n

Programming Assignment 3
Dr. CastaƱeda 1

IS 2043
Intermediate Object-Oriented Programming
Programming Assignment # 3
100 points
Due date November 10,2020

On your flash drive or on your home PC create a folder called PA03. Note: you
may save your workspace anywhere you want (PC, flash drive, etc). Now do the
following problem:
Within DrJava, you are to create the following program described below (this
entire program will be done within one file).
This is Part 1 of your program.
First, you will need to import the following:
import java.util.Scanner;
import java.nio.file.Paths;
import java.io.IOException;
import java.util.List;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Random;
You will also need to declare the following variables:
• Three strings called newName, modifyName (initialized to the null string
""), and bigRecord
• An a
ay of strings called bigRecordA
ay (this a
ay will be of size 15)
• An integer variable called index (this will be used for looping and will be
used to keep track of how many elements are used within
igRecordA
ay), and aNumber
Dr. CastaƱeda 2

• A random object called rand (it will be instantiated from the class
Random)
• A linked list object called list that will hold a list of strings declared as
List list = new LinkedList
();
You are to read the records (i.e. the lines) of each student from the file called
info2.txt (this file is given to you for this programming assignment). Look at
the exercise FunWithFiles to see how to read from a file if you have
forgotten. (Don’t forget that you should do this using a try-catch clause). The
format of the file is as follows:
last name, first name
Even though the file is within this format, the vowels are replaced by numbers.
How you manipulate these records will be described below in the description of
the method modifyVowels.
You may look at the contents of this file if you wish.
Using a while loop do the following:
• Read in each record at a time from file and store them into the string
igRecord
• Immediately print out this cu
ent record to the console
• Now invoke the method modifyVowels and pass to it the arguments
igRecord and modifyName. This method will return a string so you must
assign the returned value to the variable bigRecordA
ay (into its
appropriate element).
Close the file that you just read from. This ends the try clause. Don’t forget to
follow this with a catch clause.
Dr. CastaƱeda 3

Method modifyVowels – in this method it will receive two incoming
parameters that are both strings. Name them fullName (which is really the
argument bigRecord) and modifyName. To create this method, you must
first understand how the file info2.txt looks like. As stated previously, the
format will be last name followed by first name but all vowels are replaced by a
number. Here are the co
elations between the numbers and the vowels:
0 represents a
1 represents e
2 represents i
3 represents o
4 represents u
5 represents y
So, what you have to do in this method is replace each number in fullName by
its co
elated vowel BUT in a recursive solution. On each recursive call you will
look at the first character in fullName and if it is a number, replace it with the
proper vowel. This modification
eplacing will occur in the parameter
modifyName. Of course, if the character is not a vowel you simply concatenate
that letter with the cu
ent value of modifyName. Scanning through one
character at a time, eventually all of the characters within fullName would have
een seen (i.e. its length will become zero) and thus, you have reached the base
case. The rest of the code is what you have to figure out.
After the try-catch clause (in the main method), you are to print out the
ecords. You will do this by invoking the method printRecords and pass to it
the arguments bigRecordA
ay and index. This method will not return
anything. It is described below.
Dr. CastaƱeda 4

Method printRecords – this method will receive two parameters (look at the
two arguments talked about above). You may name these two parameters
whatever you like. Nevertheless, the method will print out the records of the
incoming a
ay (look at output for part 1 below). This method will not return
anything.
At the top of your program within the class PA3 make sure that you have the
following header filled in:
------------------------------------------------------
Programmer:
Course: IS 2043 Section ###
Semester:
Assignment #:
Due Date:
-----------------------------------------------------
Note: You must conform to good Java programming practices (i.e. spaces where
needed, indention, comments, etc.) This will be part of your grade. You should
have already learned this from your IS2033 (Java 1 course).
Expected output for the first part of your program:
Information read from file:
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:
3wn ch0rl21
Reading record 7:
0v3 j3hnn5
Reading record 8: b2rd tw11ty
Reading record 9: h1dg1h3g s3n2c
Reading record 10: j1ts3n g13rg1
Dr. CastaƱeda 5

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:
own charlie
Record 7:
avo johnny
Record 8: bird tweety
Record 9: hedgehog sonic
Record 10: jetson george
Record 11: martian marvin
This is Part 2 of your program.
In this part, you are to sort the a
ay bigRecordA
ay using the bu
le sort
that we talked about in one of our exercise (i.e. Bu
leSort). So, you will
invoke the method (call it bu
le) and pass to it the two arguments
igRecordA
ay and index.
Method bu
le – this method will have two incoming parameters (you may call
them whatever you wish). Nevertheless, the first parameter will be co
elated
with the a
ay (bigRecordA
ay). The difference between what we did in our
exercise and what you have to do here is that now the elements are strings. So,
code it appropriately. This method does not return anything.
Now that the records are sorted, you are to print out these records. You will do
this by invoking the method printRecords.
Dr. CastaƱeda 6
Expected output for the second part of your program:
Sorted records:
Record 0: bird tweety
Record 1:
avo johnny
Record 2:
own charlie
Record 3: doe john
Record 4: flintstone fred
Record 5: hedgehog sonic
Record 6: jetson george
Record 7: joel billy
Record 8: lightyear buzz
Record 9: martian marvin
Record 10: mouse mickey
Record 11: simpson home
This is Part 3 of your program.
At this point, the bigRecordA
ay is sorted. So now, you are to create a
linked list from these sorted records. You do this by invoking a method called
createLinkedList and passing to it the three arguments list,
igRecordA
ay, and index. Once you do this, you are to print out this
linked list by invoking a method called printList and passing to it only the
argument list. Both of these methods are described below.
Method createLinkedList – this method will have three parameters (you
may name them whatever you wish). This method will actually create a linked list
from the a
ay that is passed to this method. You may want to look at our
exercise GCollection2 to get an idea on how to do this if you forgot. This
method will not return anything
Dr. CastaƱeda 7

Method printList – this method will have just one parameter (you may name
it whatever you wish). This method will simply print out the linked list. However,
you must use an iterator to do this, specifically a ListIterator. You may
want to look at our exercise GCollection2 to get an idea on how to do this if
you forgot. Start from the beginning of the linked list to print out to the console.
This method will not return anything.
Expected output for the third part of your program:
Linked list records:
Record 0: bird tweety
Record 1:
avo johnny
Record 2:
own charlie
Record 3: doe john
Record 4: flintstone fred
Record 5: hedgehog sonic
Record 6: jetson george
Record 7: joel billy
Record 8: lightyear buzz
Record 9: martian marvin
Record 10: mouse mickey
Record 11: simpson home
This is Part 4 of your program.
For this part of your program, you will be generating a random number between 0
and the number of elements that exist within your linked list (hint: this number is
the same number of elements that were actually used in the a
ay
igRecordA
ay). Once you have your random number (i.e. aNumber) you
are to remove this record from the list. To remove a record from a linked list is
the opposite of adding a record to a linked list. So instead of using the method
add, you will be using the method remove. After removing this record from the
linked list, you are to you are to print out this linked list by invoking the method
Dr. CastaƱeda 8

called printList. You output should reflect that indeed this record was
emoved.
Now, simply repeat the entire process above for a second time (i.e. random
number, remove, print out linked list).
Expected output for the fourth part of your program:
Linked list records:
Record 0: bird tweety
Record 1:
avo johnny
Record 2:
own
Answered Same Day Nov 10, 2021

Solution

Aditya answered on Nov 13 2021
152 Votes
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;
---------------------------------------
Programmer:
Course
Semeste
Assingment
Due Date:
---------------------------------------
public class PA3 {
public static void main(String[] args) {
String newName = "";
String modifyName = "";
String bigRecord = "";
String bigRecordA
ay[] = new String[15];
int index =0;
int aNumber = 0;
Random rand;
List list = new LinkedList
();
File file = new File("info2.txt");
try(Scanner sc = new Scanner(file))
{
System.out.println("Reading information from file");
while (sc.hasNextLine()) {
bigRecord = sc.nextLine();
System.out.println(bigRecord);
bigRecordA
ay[index] = modifyVowels(bigRecord, modifyName);
index++;
}
System.out.println("\nModified Records");
printRecords(bigRecordA
ay, index);
buble(bigRecordA
ay, index);
createLinkedList(list, bigRecordA
ay, index);
for(int i =0; i< 2; i++)
{
printList(list);
aNumber = (int)...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions Ā»

Submit New Assignment

Copy and Paste Your Assignment Here