Question: 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

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 false 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 until a valid entry is given. If the user should select the cancel button for any input, your program should exit.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!