Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago