IS 2063: PA1 ASSIGNMENT
PLAN GRADE: PLAN (pseudocode) this program from the planning video posted in
Blackboard. 10% OF GRADE. IMPORTANT: The planning video “gives” you the logic
instructed in the UML diagram. It is the logic upon which the rest of your PAs are based, so
it is critical your PA1 follows that logic.
READ CAREFULLY “ALL” THE INSTRUCTIONS!!!
Do not submit code that doesn’t compile, run, or generate correct output.
No assistance given via email.
Seek help during open tutoring or instructor office hours.
CONTENTS: Press Alt, Left Arrow to return to table of contents.
UTSA HONOR CODE ……………………………………………………………………………………………………………………… 1
OBJECTIVE …………………………………………………………………………………………………………………………………… 2
PREP WORK: ………………………………………………………………………………………………………………………………… 2
GRADING: ……………………………………………………………………………………………………………………………………… 2
……………………………………………………………………………………………………………………….. 2
…………………………………………………………………………………………………….. 2
UML Class Diagram ………………………………………………………………………………………………………………….. 3
PROMPTS ………………………………………………………………………………………………………………………………. 3
Sequencing and Logical Control ………………………………………………………………………………………………….. 6
FINAL Output Specifications: …………………………………………………………………………………………………………….. 8
……………………………………………………………………………………………………… 9
SAMPLE OUTPUT ……………………………………………………………………………………………………………………. 9
***OUTPUT WITH NO ADDRESSES*** Not part of output. …………………………………………. 9
***OUTPUT INCORRECT/CORRECT INPUT*** Not part of output. ……………………………. 10
UTSA HONOR CODE: As a UTSA student, you are bound by the honor code, so DO NOT cheat on
any of your coursework. By submitting this assignment, you affirm that there has been no
cheating or collusion in its completion; that the material you’ve used is from your textbook,
professor, or Java tutors. Cheating can result in anyone, or combination, or all of the following:
reduced or failing grade for the assignment, a signed statement of the infraction, reduced or failing
grade for the course, reporting of student to the Department Chair, Dean’s Office, and/or elevation to
Student Conduct and Community Standards. It is not only cheating, but an infringement of copyright,
if you post this assignment or your completed code to any website for broad consumption or
distribution. The idea behind this assignment is not yours. The logic given to you for the assignment
by the faculty is not yours. The code that is written embodies the idea.
https://sso-dl.it.utsa.edu/
TOC
© 2023 Linda Shepherd 2
OBJECTIVE (this is not the program purpose): Code a program that uses the concepts covered in
chapters 1-4 and lecture.
PREP WORK: Material from chapters 1, 2, 3, and 4 (including instructor PowerPoint slides, demo
programs, and completed exercises).
GRADING: You’ll be graded on how well you follow the program instructions and the accuracy of
your output as reflected in the prompts, the output specifications, and the sample output.
This includes spacing and line advancing. Each line of output can be associated with multiple
points in the code! The instructions, prompts and output are what the user wants. You are not at
liberty to change anything, but code to these requirements. You’ll also be graded on the code given
to you by your professor for this PA.
PA CHECKLIST
☐Yes ☐No Plan completed and submitted.
☐Yes ☐No Did I declare my method-level (local) variables at the beginning of the method and
initialize them to their default values or given value?
1. 0 for int
2. 0.0 for double
3. ‘ ‘ for char (has space between the single quotes)
4. “” for String (no space between the double quotes; represents an empty String
literal)
5. null for class reference variables declared without an object
☐Yes ☐No Are my open braces on their own line?
☐Yes ☐No Did I use printf() and format specifiers by default unless instructed to use print() or
println()?
☐Yes ☐No Did I use the Java code given to me either in the instructions or the plan?
☐Yes ☐No Did I use good form?
1. My code is properly spaced, not bunched up.
2. Readable within the line of sight from top to bottom rather than extensively left to
right. Don’t go beyond the grey line in the right margin of DrJava.
3. Use Ctrl A to highlight all your code, then press the tab key to align it. If it doesn’t
align, you have a bracing error.
☐Yes ☐No Did I follow commenting guidelines?
☐Yes ☐No Does my program compile and run with the correct results, i.e., did I follow formatting
guidelines?
PROGRAM INSTRUCTIONS:
1. Create a program for address books.
2. Work and submit this PA on your own (no partner).
3. Commenting Your Program: Refer to the Java Style Guide posted in Blackboard for more
commenting and formatting details. Java doc comment box examples are given to you in
https://sso-dl.it.utsa.edu/
TOC
© 2023 Linda Shepherd 3
PowerPoint slides and may have been given to you in demo programs coded during class or
through a video posted by your professor.
a. In your program, YOU MUST insert a program purpose in the first comment box. The
content of that first comment box was shown to you in the Anatomy of a Java Program lecture
for chapter 1.
b. Use Javadoc comment boxes beginning with /** and ending with */ for your comment boxes.
c. Insert a Javadoc comment box above all your methods explaining what is going on with the
code in the method.
d. Line comment the import statements and the variables declared at the class level and/or in any
method [including main()].
e. Line comment close braces. The close brace for an else in an if-else is where you line
comment for the structure. Line comment after the while in a do-while.
4. Formatting Rules: Always test to validate your program is functioning properly with the correct
output and spacing (line advances and spacing after punctuation) in the output. The %n can
function differently when using separate printf() statements versus one printf().
5. UML Class Diagram: Data members are variables. The variables can be derived from the
prompts and/or the output. The complete code for the PA is outlined in logical progression within
this UML.
Class Name YourLastNameFirstInitialYourSectionNoPA1
Example: ShepherdL001PA1
Class
Data
Members
N/A
Method
Data
Members
input: Scanner
phoneFormatted: StringBuilder
another, anotherAddress, correct: char
ownerAddrBk, addressee, street, cityStateZip, phone, work,
addressBook: String
//Initialize to “FAMILY” and “FRIENDS”
family, friends: String
relationship, bookType: int
Methods +main(args: String[]): static void
PROMPTS: Code what is in bold from the prompts below in printf()
statements for capturing data. The actual output is not in bold. The prompts
tell you your input variables.
1st Prompt: This primes the sentinel-loop control variable another before
entering the while that controls the address books.
Begin entering addresses? ‘Y’ or ‘N’:
TOC
© 2023 Linda Shepherd 4
If answer is not ‘Y’, print this message, then exit the program.
Exiting program.
2nd Prompt: This is for the type of address book, bookType. This prompt is in
a validation do-while that is nested within the while. The do-while is controlled
by the sentinel-control variable correct.
Address Book Type:
1. Personal
2. Business
Choose from above the address book type:
You entered 9 for Xxxxxxxx. Is this correct? ‘Y’ or ‘N’:
Where 9 is either a bookType of 1 or 2 and the Xs are either “PERSONAL” or
“BUSINESS”.
OR
You entered 9 which is the wrong address book type. Try again.
Where the 9 is a bookType other than 1 or 2 and where the variable correct is
initialized to ‘n’.
3rd Prompt: This is for the owner of the address book, ownerAddrBk. It is in
a validation do-while that is nested within the while. The do-while is controlled
by the sentinel-control variable correct.
Enter your name:
This is followed by the prompt for the validation loop-control variable correct.
You entered Xxxxxxxxxxxx. Is this correct? ‘Y’ or ‘N’:
Where the Xs are the name of the address book owner.
4th Prompt: This prompts for the addressee. It is in a validation do-while that
is nested within the multiple addresses do-while that is within the while. The
validation do-while is controlled by the sentinel-control variable correct.
Enter the name of the addressee:
This is followed by the prompt for the validation loop-control variable correct.
You entered Xxxxxxxxxxxx. Is this correct? ‘Y’ or ‘N’:
TOC
© 2023 Linda Shepherd 5
Where the Xs are the name of the addressee.
5th Prompt: This prompts for the street address. It is in a validation do-while
that is nested within the multiple addresses do-while that is within the while.
Where the Xs represent the addressee’s name. The validation do-while is
controlled by the sentinel-control variable correct.
Enter the street for Xxxxxxxxxxxx:
This is followed by the prompt for the validation loop-control variable correct.
You entered Xxxxxxxxxxxx. Is this correct? ‘Y’ or ‘N’:
Where the Xs are the street.
6th Prompt: This prompts for the cityStateZip. It is in a validation do-while
that is nested within the multiple addresses do-while that is within the while.
Where the Xs represent the addressee’s name. The validation do-while is
controlled by the sentinel-control variable correct.
Enter the city, state and zip code for Xxxxxxxxxxxx in the correct format:
This is followed by the prompt for the validation loop-control variable correct.
You entered Xxxxxxxxxxxx. Is this correct? ‘Y’ or ‘N’:
Where the Xs are the city, state and zip code.
7th Prompt: This prompts for the phone number. It is in a validation do-while
that is nested within the multiple addresses do-while that is within the while.
Where the Xs represent the addressee’s name. The validation do-while is
controlled by the sentinel-control variable correct.
Enter the 10 digit phone number for Xxxxxxxxxxxx without dashes or
parentheses:
After formatting the phone number using StringBuilder, there is the following
prompt for the validation loop-control variable correct.
You entered Xxxxxxxxxxxx. Is this correct? ‘Y’ or ‘N’:
Where the Xs are the phone number.
8th Prompt: This prompts for the relationship of the addressee to the address
book owner. It is in a validation do-while that is nested within the multiple
addresses do-while that is within the while. The validation do-while is
controlled by the sentinel-control variable correct.
TOC
© 2023 Linda Shepherd 6
Relationship of addressee:
1. Family
2. Friends
3. Work
Choose from the above:
Then a switch statement evaluates the relationship variable to determine the
prompt for the validation loop-control variable correct.
You entered 9 for Xxxxxxxxx. Is this correct? ‘Y’ or ‘N’:
Where 9 is either a relationship of 1 or 2 and the Xs are either “Family” or
“Friends”.
OR
You entered 3 for Work. Is this correct? ‘Y’ or ‘N’:
OR
You entered 9 which is incorrect. Try again.
Where 9 is a relationship value other than 1, 2, or 3.
9th Prompt: This alters the sentinel-loop control variable anotherAddress to
either continue with another address or exit the do-while loop.
Do you want to enter another address? ‘Y’ or ‘N’:
10th Prompt: This alters the sentinel-loop control variable another to either
continue with another address book or exit the while loop.
Do you want to create another address book? ‘Y’ or ‘N’:
Sequencing and Logical Control: The following instructions give you the
logical order of the code. The nesting of the logical structures and their Java
statements are indented.
1. Prompt 1
2. Use if to print the message “Exiting program.” as long as another is not
‘Y’.
3. Use a sentinel-controlled while loop to process multiple address books
controlled by another as long as it is ‘Y’.
a. Use a sentinel-controlled do-while loop controlled by correct to prompt
for and validate the bookType as long as correct is not ‘Y’. NOTE:
Reflected as 3a because it is nested within the while.
TOC
© 2023 Linda Shepherd 7
i. Prompt 2 NOTE: Reflected as 3ai because it is nested within the
do-while that is within the while.
ii. Use a switch to print the validation prompts for bookType.
b. Initialize the address book to its title using a ternary:
c. Use a do-while controlled by correct to prompt for and validate the
name of the address book owner (prompt 3) as long as correct is not
‘Y’.
d. Add the name of the address book owner to the address book:
e. Use a do-while controlled by anotherAddress to process additional
addresses for an address book as long as anotherAddress is ‘Y’.
1) Use a do-while controlled by correct to prompt for and validate the
name of the addressee (prompt 4) as long as correct is not ‘Y’.
2) Use a do-while controlled by correct to prompt for and validate the
street address of the addressee (prompt 5) as long as correct is not
‘Y’.
3) Use a do-while controlled by correct to prompt for and validate the
city, state, and zip of the addressee (prompt 6) as long as correct is
not ‘Y’.
4) Use a do-while controlled by correct to prompt for and validate the
10 digit phone number for the addressee (prompt 7) as long as
correct is not ‘Y’.
a) Right after you capture the phone number you’ll use the
StringBuilder object to insert dashes into the phone number.
5) Use a do-while controlled by correct to validate the relationship of
the addressee to the address book owner (prompt 8) as long as
correct is not ‘Y’.
a) Use a switch
i) with a fall-through for cases 1 and 2 to validate the
relationship of the addressee to the address book owner.
ii) The work message in case 3.
iii) The incorrect message in default. Initialize correct to ‘n’ in
the default.
6) Use a switch outside of the relationship do-while to assign the
address information to the String objects family, friends, and work.
7) Prompt 9
f. Use a switch to print the personal or business addressBook that stores
the address book header and name of address book owner.
g. Prompt 10
4. Exit.
5. The Prompts, the output specs, and the sample output show you in what
order to place your code. To return from these links press Alt, left arrow.
6. You are to generate output from your program according to the instructions
in the sample output section.
TOC
© 2023 Linda Shepherd 8
FINAL OUTPUT SPECIFICATIONS: The output will print the header, address category, addressee’s
name, street, city, state, zip code, and phone number. The specifications are repeated because there
can be multiple addresses. The Xs represent the name of the owner of the address book, the
addressee, the street, city and capitalized abbreviation for the state. The 9s represent the zip code
and phone number.
PERSONAL ADDRESS BOOK FOR XXXXXXXXXXXX
FAMILY
Addressee: Xxxxxxxxxxxx
Street: Xxxxxxxxxxxx
City, State Zip: Xxxxxxxxxx, XX xxxxx
Phone: xxx-xxx-xxxx
Addressee: Xxxxxxxxxxxx
Street: Xxxxxxxxxxxx
City, State Zip: Xxxxxxxxxx, XX xxxxx
Phone: xxx-xxx-xxxx
FRIENDS
Addressee: Xxxxxxxxxxxx
Street: Xxxxxxxxxxxx
City, State Zip: Xxxxxxxxxx, XX xxxxx
Phone: xxx-xxx-xxxx
Addressee: Xxxxxxxxxxxx
Street: Xxxxxxxxxxxx
City, State Zip: Xxxxxxxxxx, XX xxxxx
Phone: xxx-xxx-xxxx
OR
BUSINESS ADDRESS BOOK FOR XXXXXXXXXXXX
Addressee: Xxxxxxxxxxxx
Street: Xxxxxxxxxxxx
City, State Zip: Xxxxxxxxxx, XX xxxxx
Phone: xxx-xxx-xxxx
Addressee: Xxxxxxxxxxxx
Street: Xxxxxxxxxxxx
City, State Zip: Xxxxxxxxxx, XX xxxxx
Phone: xxx-xxx-xxxx
***END OUTPUT SPECIFICATIONS***
Header (Title): Triple-line advance header
title using 2 “%n” with 1 %n at the end of the
literal. Use 1 “%n” at the beginning of the 2nd
header line and 1 at the end. All capital Xs
means the owner’s name is in all CAPS.
TOC
© 2023 Linda Shepherd 9
SUBMISSIONS REQUIREMENT:
1. Plan: Upload your plan to Blackboard under this PA.
2. Word Document: Copy your .java code into a Word document and save it with the same name
as your program. Upload the document to Blackboard under this PA.
3. Zipping Folders: Your Java files “must be” in a folder.
a. Create a folder named for the program (excluding the file extension).
b. Put your .java, .class, .java~ files in the folder. You must have all 3 files. Points will be
deducted if you don’t.
c. Put your completed PA1 plan Word document in the folder.
d. To zip the folder, point to it then right click and
i. Filzip if you have it OR
ii. Click Send To then click Compressed (zipped) Folder
e. Upload your zipped folder to Blackboard under this PA.
4. Uploading to Blackboard: Make sure your browser is properly configured for Blackboard
(see syllabus).
a. Your submissions are to be uploaded to Blackboard through Assignments only.
b. Upload your files no later than the due date by 11:55 pm; otherwise, you don’t have time to
recover from any problems and your assignment may not be accepted by Blackboard.
c. Check to make sure your submission is uploaded. Please do not ask your instructor to
check whether your assignment has been uploaded. You can do this yourself. Or upload
during a tutoring session when someone can help you.
d. If you submit your assignment before the due date, want to make changes or upload additional
files, you can re-upload your files.
5. NO ASSIGNMENTS WILL BE ACCEPTED LATE OR VIA E-MAIL. DO NOT SUBMIT
PROGRAMS THAT DON’T COMPILE OR RUN (AUTOMATIC ZERO) OR DON’T PRODUCE
CORRECT OUTPUT.
SAMPLE OUTPUT: It is always good to test your code using sample data to see if your program
meets the output specifications. Run your program using the data in the following sample
output. Copy and paste the output into a traditional comment box at the end of your PA1.java
file. The comment box needs to be outside of the close brace for the class. Change your font in
DrJava to Monospaced or Courier New if your output is out of alignment. Worth 5 points!
Your output will not print in bold. The TOC in the top right-hand corner of the page is not part of
the output. It takes you to the table of contents on page 1.
***OUTPUT WITH NO ADDRESSES*** Not part of output.
Begin entering addresses? ‘Y’ or ‘N’: n
Exiting program.
https://sso-dl.it.utsa.edu/
TOC
© 2023 Linda Shepherd 10
***OUTPUT INCORRECT/CORRECT INPUT*** Not part of output.
Begin entering addresses? ‘Y’ or ‘N’: y
Address Book Type:
1. Personal
2. Business
Choose from above the address book type: 3
You entered 3 which is the wrong address book type. Try again.
Address Book Type:
1. Personal
2. Business
Choose from above the address book type: 2
You entered 2 for Business. Is this correct? ‘Y’ or ‘N’: n
Address Book Type:
1. Personal
2. Business
Choose from above the address book type: 1
You entered 1 for Personal. Is this correct? ‘Y’ or ‘N’: y
Enter your name: James Kork
You entered James Kork. Is this correct? ‘Y’ or ‘N’: n
Enter your name: James Kirk
You entered James Kirk. Is this correct? ‘Y’ or ‘N’: y
Enter the name of the addressee: Jorge Kirk
You entered Jorge Kirk. Is this correct? ‘Y’ or ‘N’: n
Enter the name of the addressee: George Kirk
You entered George Kirk. Is this correct? ‘Y’ or ‘N’: y
Enter the street for George Kirk: 123 Main
TOC
© 2023 Linda Shepherd 11
You entered 123 Main. Is this correct? ‘Y’ or ‘N’: n
Enter the street for George Kirk: 718 Enterprise Cir
You entered 718 Enterprise Cir. Is this correct? ‘Y’ or ‘N’: y
Enter the city, state and zip code for George Kirk in the correct format:
Riverdale, CA All on one line in DrJava (text wrapped in Word).
You entered Riverdale, CA. Is this correct? ‘Y’ or ‘N’: n
Enter the city, state and zip code for George Kirk in the correct format:
Riverside, IA 52327 All on one line in DrJava.
You entered Riverside, IA 52327. Is this correct? ‘Y’ or ‘N’: y
Enter the 10 digit phone number for George Kirk without dashes or
parentheses: 7197890123 All on one line in DrJava.
You entered 719-789-0123. Is this correct? ‘Y’ or ‘N’: n
Enter the 10 digit phone number for George Kirk without dashes or
parentheses: 3197890123 All on one line in DrJava.
You entered 319-789-0123. Is this correct? ‘Y’ or ‘N’: y
Relationship of the addressee:
1. Family
2. Friends
3. Work
Choose from the above: 4
You entered 4 which is incorrect. Try again.
Relationship of the addressee:
1. Family
2. Friends
3. Work
Choose from the above: 2
You entered 2 for Friends. Is this correct? ‘Y’ or ‘N’: n
Relationship of the addressee:
1. Family
2. Friends
TOC
© 2023 Linda Shepherd 12
3. Work
Choose from the above: 1
You entered 1 for Family. Is this correct? ‘Y’ or ‘N’: y
Do you want to enter another address? ‘Y’ or ‘N’: y
Enter the name of the addressee: Spock
You entered Spock. Is this correct? ‘Y’ or ‘N’: y
Enter the street for Spock: 15 Triple Moon
You entered 15 Triple Moon. Is this correct? ‘Y’ or ‘N’: y
Enter the city, state and zip code for Spock in the correct format:
Surak, Vulcan All on one line in DrJava.
You entered Surak, Vulcan. Is this correct? ‘Y’ or ‘N’: y
Enter the 10 digit phone number for Spock without dashes or parentheses:
4151234567 All on one line in DrJava.
You entered 415-123-4567. Is this correct? ‘Y’ or ‘N’: y
Relationship of the addressee:
1. Family
2. Friends
3. Work
Choose from the above: 2
You entered 2 for Friends. Is this correct? ‘Y’ or ‘N’: y
Do you want to enter another address? ‘Y’ or ‘N’: n
PERSONAL ADDRESS BOOK FOR JAMES KIRK
FAMILY
Addressee: George Kirk
Street: 718 Enterprise Cir
City, State Zip: Riverside, IA 52327
Phone: 319-789-0123
FRIENDS
TOC
© 2023 Linda Shepherd 13
Addressee: Spock
Street: 15 Triple Moon
City, State Zip: Surak, Vulcan
Phone: 415-123-4567
Do you want to create another address book? ‘Y’ or ‘N’: y
Address Book Type:
1. Personal
2. Business
Choose from above the address book type: 2
You entered 2 for Business. Is this correct? ‘Y’ or ‘N’: y
Enter your name: James Kirk
You entered James Kirk. Is this correct? ‘Y’ or ‘N’: y
Enter the name of the addressee: Star Fleet Command
You entered Star Fleet Command. Is this correct? ‘Y’ or ‘N’: y
Enter the street for Star Fleet Command: 1 Star Fleet
You entered 1 Star Fleet. Is this correct? ‘Y’ or ‘N’: y
Enter the city, state and zip code for Star Fleet Command in the correct
format: Fort Baker, CA 98210 All on one line in DrJava.
You entered Fort Baker, CA 98210. Is this correct? ‘Y’ or ‘N’: y
Enter the 10 digit phone number for Star Fleet Command without dashes or
parentheses: 4158921519 All on one line in DrJava.
You entered 415-892-1519. Is this correct? ‘Y’ or ‘N’: y
Relationship of the addressee:
1. Family
2. Friends
3. Work
Choose from the above: 3
You entered 3 for Work. Is this correct? ‘Y’ or ‘N’: y
Do you want to enter another address? ‘Y’ or ‘N’: y
TOC
© 2023 Linda Shepherd 14
Enter the name of the addressee: Lt. Commander Montgomery Scott
You entered Lt. Commander Montgomery Scott. Is this correct? ‘Y’ or ‘N’:
y All on one line in DrJava.
Enter the street for Lt. Commander Montgomery Scott: 5 Star Fleet #62
You entered 5 Star Fleet #62. Is this correct? ‘Y’ or ‘N’: y
Enter the city, state and zip code for Lt. Commander Montgomery Scott in
the correct format: Fort Baker, CA 98210 All on one line in DrJava.
You entered Fort Baker, CA 98210. Is this correct? ‘Y’ or ‘N’: y
Enter the 10 digit phone number for Lt. Commander Montgomery Scott without
dashes or parentheses: 4152345678 All on one line in DrJava.
You entered 415-234-5678. Is this correct? ‘Y’ or ‘N’: y
Relationship of the addressee:
1. Family
2. Friends
3. Work
Choose from the above: 3
You entered 3 for Work. Is this correct? ‘Y’ or ‘N’: y
Do you want to enter another address? ‘Y’ or ‘N’: n
BUSINESS ADDRESS BOOK FOR JAMES KIRK
Addressee: Star Fleet Command
Street: 1 Star Fleet
City, State Zip: Fort Baker, CA 98210
Phone: 415-892-1519
Addressee: Lt. Commander Montgomery Scott
Street: 5 Star Fleet #62
City, State Zip: Fort Baker, CA 98210
Phone: 415-234-5678
Do you want to create another address book? ‘Y’ or ‘N’: n
-
TOTAL POINTS: 100
- PLAN GRADE: PLAN (pseudocode) this program from the planning video posted in Blackboard. 10% OF GRADE. IMPORTANT: The planning video “gives” you the logic instructed in the UML diagram. It is the logic upon which the rest of your PAs are based, so it is critical your PA1 follows that logic.
DUE: CHECK BLACKBOARD BY 11:59 PM Plan and PA have separate due dates.
PA CHECKLIST
PROGRAM INSTRUCTIONS:
SUBMISSIONS REQUIREMENT:
***OUTPUT WITH NO ADDRESSES*** ( Not part of output.
***OUTPUT INCORRECT/CORRECT INPUT*** ( Not part of output.