Complete the programming assignment please, all together, one code in java
Programming Assignment 3
@ 2022 Dr. Robert Castañeda 1
Programming Lang II with Java
Programming Assignment # 3
Due date August 5, 2022
On your flash drive, laptop, or on your home PC create a folder for your PA.
Name your folder in the following manner:
lastNameFirstInitialOfYourFirstNameCourseSectionPA3. So, for example if I
were creating this folder for my PA and given that my name is Robert Castaneda
and let’s say that I was in section 001, my folder name would be
Next, do the following:
Within DrJava, you are to create a Java class for your PA. Like for your folder
(above), use the same procedure in naming your PA class. So again, for example,
if I were creating the class for my PA and given that my name is Robert Castaneda
and let’s say that I was in section 001, my class name for my PA would be
Now, your PA will show records of people’s names and their age. Your program
will manipulate these records in the appropriate way talked about below. The
information about these people (there will be 12 of them) will be read in from a
1) First, you will need to import the following:
@ 2022 Dr. Robert Castañeda 2
The following are variables and constants that you will need to declare in your
program (within the main() method):
fullName (assigned the null string “”), firstName, lastName, oneLetter,
and bigRecord will be strings
bigRecordArray will be an array of strings of size 15
tokens will be an array of strings
index (assigned the value 0) and age will be integers
You will be reading from a file that is called info.txt. So please set up the file
as shown in Chapter 4. You may want to specifically look at pages 237 through
244 as a guidance.
2) You will need to read the information from the file info.txt and store it
inside your bigRecord. You will need a while loop to do this. There are
three items per record (a person). They are: the person’s last name, the
person’s first name, and the person’s age. However, for each person their last
name and first name are encrypted. More about this later.
You are to add the words throws IOException on the same line as your
main() method so that it looks like this:
public static void main(String args) throws IOException
After reading in each record of a person, you are to print it out (look at the
expected output below as use it as a guide).
3) Next, you are to use the split() method to split up the contents of
bigRecord and assign it to tokens. Use a single space as a delimiter.
@ 2022 Dr. Robert Castañeda 3
(Even though the file is within the format described earlier, the vowels are
replaced by numbers. How you manipulate these records will be described
later in the description of the method modifyVowels() ).
Next, you are to invoke the method modifyVowels() and pass to it the last
name of the person (this is represented by tokens). The returned value
from modifyVowels() will be assigned to lastName. Now convert all
letters in lastName to upper case.
Now, extract out first letter of lastName and assign it to oneLetter (usage
of the method substring() will be helpful here).
Next, extract all of the remaining letters within lastName (excluding the first
letter) and convert them to lower case and reassign it to lastName (again,
usage of substring() will be helpful here).
Finally, concatenate the oneLetter to lastName and reassign this to
Now for the firstName. You are to invoke the method modifyVowels()
and pass to it the first name of the person (this is represented by
tokens). The returned value from modifyVowels() will be assigned
to firstName. Now convert all letters in firstName to upper case.
Next, you are to concatenate the firstName, a single space, and the
lastName together and assign it to fullName.
For the age of the person, you are to parse tokens to an integer value
and assign it to the variable age (usage of Integer.parseInt() will be
@ 2022 Dr. Robert Castañeda 4
Now you are to invoke the method updateAge() and pass to it the
argument age. The return value will be reassigned to the variable age.
Next, convert age back to a String and reassign it to tokens (usage of
Integer.toString() will be useful here).
Finally, concatenate fullName, a single space, and tokens together
and assign it to bigRecordArray using index as a subscript.
Update index appropriately also.
After this while loop, close the file.
4) Outside the while loop that you created in steps 2 and 3 above, you are to
now print out a header and invoke the method printRecords() and pass
to it bigRecordArray and index to print out the records of the people.
5) Now you are to invoke method selectionSort() and pass to it
bigRecordArray and index. Now print out a header and invoke the
method printRecords() and pass to it bigRecordArray and index
to print out the newly sorted records of the people.
6) Also, make sure that you have comment header block at the top of your
program and is filled in. The generic comment header block will look something
like the following:
* Programmer: xxx xxx<-- your name goes here (first name followed by last name)
* Course: IS 2063.xxx <-- where xxx is your section number
* Programming Assignment # xxx <-- fill in appropriate assignment number for xxx
@ 2022 Dr. Robert Castañeda 5
* Due date: xxx x, xxxx <-- fill in the appropriate due date (month day, year)
Make sure your program has general comments throughout your code. Look at
my videos for examples.
The comment header block and the general comments will be worth points in
your overall grade for this assignment.
Here are brief descriptions of each of these methods and what you need to know
to code them:
modifyVowels() – in this method it will receive one incoming parameter that
is of type String (look at the argument talked about above). You may name
this parameter whatever you like. As stated previously, the names in the file (last
and first name) are encrypted in the following manner: all vowels are currently
replaced by a number. Here are the correlations between the numbers and the
0 represents a
1 represents e
2 represents i
3 represents o
4 represents u
5 represents y
You should declare three local variables. The first will be of type int and so will
the second. The third will be of type String and should be assigned the null
string “”. You will need to use a for loop, so one of your local int variables
should be the loop variable and the other local int variable should be assigned
the length of the incoming parameter. This length is the method length() not
the property length that is associated with arrays. So, the condition of your for
@ 2022 Dr. Robert Castañeda 6
loop should incorporate this “length value”. Your for loop will loop through your
parameter string character by character on every iteration and will look at each
character and determine what symbol it represents (look above for this
description). You should use a switch statement for this (usage of the method
charAt() will be useful here).
On each iteration you will look at a character in your parameter and if it is a
number, replace it with the proper vowel. It is your third local variable (that is of
type String) that will be “built up” from all of this action. Of course, if the
character is not a vowel (i.e., a consonant) you simply concatenate that letter
with the current value of your parameter. Scanning through one character at a
time, eventually all of the characters within your parameter would have been
seen and in the end your String local variable will be a complete string with all
This method will return the final value of your third local variable (the String
updateAge() – this method will receive one parameter (look at the argument
talked about above). You may name this parameter whatever you like. You
should declare two local variables. The first will be of type int and the second
will be an object instantiated from the Random class. Randomly generate a
number and assign this value to the local variable that you declared. You should
generate numbers between 0 and 3 inclusive. So, pass the number 4 as an
argument to your random number generator to accomplish this. Using this
random number, use it in a switch statement to determine what kind of update
needs to be done to your parameter. The possible outcomes are as follows:
0 - increment your parameter by 1
1 - decrement your parameter by 1
2 - increment your parameter by 2
otherwise - assign the value 21 to your parameter
@ 2022 Dr. Robert Castañeda 7
This method will return the value that you assigned to your parameter.
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
array (don’t forget to make usage of the second parameter). You should declare a
local variable that is of type int that you will need in this method as the loop
variable. This method will not return anything.
selectionSort() – this method will have two incoming parameters (you may
call them whatever you wish). Nevertheless, the first parameter will be
correlated with the array bigRecordArray (don’t forget to