Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Vernon Hills Mail-Order Company often sends multiple packages per order. For each customer order, print enough mailing labels to use on each of the

The Vernon Hills Mail-Order Company often sends multiple packages per order. For each customer order, print enough mailing labels to use on each of the separate boxes that will be mailed. The mailing labels contain the customers complete name and address, along with a box number in the form Box 9 of 9. For example, an order that requires three boxes produces three labels: Box 1 of 3, Box 2 of 3, and Box 3 of 3. Produce enough mailing labels for each order. Back then, we developed pseudocode that accomplished the logic and continued to process label requests until EOF was reached on the input file. This time, we will prompt the user to tell us when he or she is done and no further labels are needed. Specifically, our application will: Continuously accept a customers title, first name, last name, street address, city, state, zip code, and number of boxes in the order and produce the labels until an appropriate sentinel value is entered. After producing the first set of labels, your application will ask the user if s/he wishes to produce another set of labels. If the user response is Y or y the user is prompted for the input for the new set of labels. A user response that is anything other than Y or y means no further labels are needed and your program should end. The following pseudocode conveys this logic: start

Declarations

string title

string firstName

string lastName

string streetAddress

string city

string state

string zip

num numBoxes

num count

string enterAnother enterAnother = Y

while enterAnother is Y or y

input title, firstName, lastName, streetAddress, city, state, zip, numBoxes

count = 1

while count <= numBoxes

output title, firstName, lastName

output streetAddress

output city, state, zip

output Box , count, of , numBoxes

count = count + 1

endwhile

input enterAnother

endwhile

stop

From Java Chapter 2: Logical operators (and-or logic) From Java Chapter 4: equals() and compareTo() methods (pp. 52-54) From Java Chapter 5: Loop controlled by a sentinel value input by the user (while statement) Loop controlled by a counter (while statement or for statement, your choice) Nested loops Tips for converting this logic to Java: 1. You will use a dialog box to get each input from the user (the 7 name/address elements, the number of boxes, and the Y or N response after producing a set of labels). You will call the JOptionPane.showInputDialog() method to accomplish each dialog box. 2. All of the input you are soliciting from the user is String, except for numBoxes. This means that you dont need to use a method to convert any input other than numBoxes to numeric. You will use the Integer.parseInt method to convert the numBoxes String input to an integer. (Note, it is okay to leave zip as String because you are not doing math or numeric compares with it.) 3. The EOF logic involves an indefinite loop controlled by a sentinel value input by the user: o Design your application so that after you produce a set of labels for the user, you then prompt the user: Do you want to produce more labels? Y or N. o You will use a while statement for this EOF logic, continuing the loop until you receive something other than Y or y from the user. o You will need to define a variable to hold the Y-or-N input from the user. Remember to properly initialize this variable so that the first set of label info from the user is processed correctly. (Note, this logic is included in the pseudocode be sure to use the good work we did in developing that pseudocode!) o When comparing String values, remember to use a String method! 4. The label-producing loop logic is a counter-controlled loop. I suggest you first code this inner loop using a while statement, as that maps well to the pseudocode we have. Once you have your program working, then I encourage you to try using the Java for statement and Java increment operator (++) to accomplish the same logic. 5. The rhythm of your interface with the user is as follows. Screen prints are provided on the next page to help you visualize the user interface: o Use our method from class JOptionPane to prompt the user for several inputs, one at a time: title, firstName, lastName, streetAddress, city, state, zip, numBoxes o Use println() method to produce the label output to the user. o Use our method from class JOptionPane to ask if the user would like to produce more labels. If Y or y, send the input prompts again (title, firstName, lastName, etc.). Otherwise, end the program.

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

=+ Why have these changes occurred?

Answered: 1 week ago

Question

=+90 percent of all oil refineries) into several smaller companies

Answered: 1 week ago