Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this laboratory assignment, create a Java program that prompts the user for an address in pieces, and then presents their completed address. For example,

image text in transcribed
In this laboratory assignment, create a Java program that prompts the user for an address in pieces, and then presents their completed address. For example, prompt for their street number, street, city, province, and postal code. Use a JOptionPane input dialog to get the Strings, and a JOption message dialog to present the completed address Your program should consist of two classes a lab two class (give this class an appropriate name}, and an Address class. The first class contains the main method and prompts the user for Strings, while the second class contains the data and methods for storing and synthesizing the address. Your Address class should contain private data members. Use accessor methods to set and retrieve the five data members (one int and four Strings). Each access method to set a value should have a String parameter, and return true if the value was set and faise otherwise. The accessor methods to retrieve a value should take no parameters, and return an int or String as appropriate. Your setStreetNumber and setPostalCode accessor methods should verify a correct format before returning true to indicate the value has been set. For example, the number should be a valid number, and the postal code should be a valid postal code (letter number, letter, number letter number and only six or seven (with a space) digits long.). A valid postal code may or may not contain a space, but should be stored with a space. Your Address class must override the toString method and return a String, which is the address to display to the user. Your main method should keep prompting for a street number or postal code unti a valid entry is given. If the user should select the cancel button for any input, your program should exit. Example Code for JOptionPane string s optionPane showInputDialog("Message Goes Here"); 17(5 = null) System.exit(1); ) JoptionPane shoulessageDialog(null, 5. "Message", optionPane. INFORMATION PESSAGE ); This code snippet is here for you to use if you want. You do not necessarily need to do it this way. Submission Use JavaDoc to comment your program, remembering to comment each class and method. Include your name, student ID. class, and assignment type and number in a regular comment, at the top of each source file. Remember to run the command Javadoc filename for both classes (if you have them in separate files) When your program is completed, demonstrate it to the instructor, and upload your java source files to Moodle with a screen shot, all in a jar file. Use the far er Lase nane Lab2. Jar Lab2 command to put it in a jar file. Assignments that do not compile or run may be awarded a mark of zero... Enjoy :) Hints: You may want private isNumber) and isLetter() functions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

Define Leap year?

Answered: 1 week ago

Question

Prepare a short profile of Lucy Clifford ?

Answered: 1 week ago

Question

Prepare a short profile of Rosa parks?

Answered: 1 week ago

Question

Prepare a short profile of victor marie hugo ?

Answered: 1 week ago