Question: SplitZip: Write an application that prompts the user to enter in a 10 character zip code with a - between the two sections, such as

SplitZip: Write an application that prompts the user to enter in a 10 character zip code with a - between the two sections, such as 49442-1432 Use the split() method to separate the zip code into its two parts and display them separately.

package pack1; import javax.swing.*; public class SplitZip { public static void main(String[] args) { String inputString; String newString; inputString = JOptionPane.showInputDialog(null, "Enter a Zip Code" + " as a series of 10 digits" + " and I will display it in a nice format" + " Enter 999 to quit"); while(!inputString.equals("999")) { newString = inputString.substring(0,6) + '-' + inputString.substring(6,10) ; String[] newerString = newString.split("-"); for(String temp :newerString ) { inputString = JOptionPane.showInputDialog(null, "The number is " + temp + " Enter azip code" + " as a series of 10 digits " + " and I will display it in a nice format" + " Enter 999 to quit"); } } System.exit(0); } }

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!