The Vernon Hills MailOrder Company often sends multiple pack

The Vernon Hills Mail-Order Company often sends multiple packages per order. For each customer order, output enough mailing labels to use on each of the boxes that will be mailed. The mailing labels contain the customer’s 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. Design an application that reads records that contain a customer’s title (for example, Mrs.), first name, last name, street address, city, state, zip code, and number of boxes. The application must read the records until eof is encountered and produce enough mailing labels for each order. I need the code in Java to carry out this program using JOption pane to obtain input

Solution

Ans:

import javax.swing.JOptionPane;
import java.util.ArrayList;
class MailOrder
{
   public static void main(String args[])
   {
       System.out.println(\"Please enter details and enter key to terminate\");
ArrayList<String> title=new ArrayList<String>();
ArrayList<String> fname=new ArrayList<String>();
ArrayList<String> lname=new ArrayList<String>();
ArrayList<String> address=new ArrayList<String>();
ArrayList<String> city=new ArrayList<String>();
ArrayList<String> state=new ArrayList<String>();
ArrayList<String> zip=new ArrayList<String>();
ArrayList<Integer> boxes=new ArrayList<Integer>();

do{
String t=JOptionPane.showInputDialog(\"Enter title\");
if(t== null || t.length()==0) //it is true when length of title is zero i.e EOF
   break;
String f=JOptionPane.showInputDialog(\"Enter first name\");
String l=JOptionPane.showInputDialog(\"Enter last name\");
String ad=JOptionPane.showInputDialog(\"Enter address\");
String ci=JOptionPane.showInputDialog(\"Enter city\");
String st=JOptionPane.showInputDialog(\"Enter state\");
String z=JOptionPane.showInputDialog(\"Enter zip code\");
int b=Integer.parseInt(JOptionPane.showInputDialog(\"Enter Number of boxes\"));
title.add(t);fname.add(f);lname.add(l);address.add(ad);city.add(ci);state.add(st);zip.add(z);
boxes.add(b);

}while(true);

//Mailing labels
for(int i=0;i<title.size();i++)
       {
System.out.println(\"Title           :\"+title.get(i));
System.out.println(\"First Name       :\"+fname.get(i));
System.out.println(\"Last Name       :\"+lname.get(i));
System.out.println(\"Address           :\"+address.get(i));
System.out.println(\"City           :\"+city.get(i));
System.out.println(\"State           :\"+state.get(i));
System.out.println(\"Zip Code       :\"+zip.get(i));
System.out.println(\"Number of Boxes       :\"+boxes.get(i));
int box=boxes.get(i);
System.out.println(\"Box lables\");
for(int j=1;j<=box;j++)
   System.out.printf(\"Box%d of %d\\t \",j,box);

System.out.println();
       }//end of for loop


   }//end of main
}//end of MailOrder

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site