I have this program that i need to get done for school, and i am utterly lost. If someone could help me with it, the help would be greatly appreciated.
heres the template i was given:
public class StringParse
{
public static void main(
String[] args)
{
// Variable for user input
// get the input from a user and remove the leading and trailing white spaces
// send the string to a method for manipulation
} // end main
public static void createAddress ( String address)
{
// variable for array of type string ( make it large enough to hold 35 strings)
// create a variable to hold a line of the address
// create a variable to hold an individual
word or comma
// create a variable to hold the index of a space in a string
// create a variable to hold the index of the next comma in your string
// set a variable to be the index of your array and initialize it
// use a loop to go through the string -- a while loop that looks at the size of the string
while( ) // loop through the string while it is not empty
{
// remove white space
// look for the first comma in the string and set a variable with that value
// if you find a comma you need to pull off the part before it
if ( )
{
// if no comma is found you are at the last line
// set your variable to your entire string
// set your address string to empty
}
else
{
// otherwise you need to pull off the part up to the comma
// this will represent one line of the address
}
// while the part you removed has at least 1 character
while( )
{
// trim the current part
// find the first [space] in the string
// if no space is found than your string only contains the last word
// or character in that line of the address
// if it has a space you will need to pull the part of before the space
if ( )// no space found
{
// you will need to remove the empty spaces
// and enter that string into your array of strings
// set current part = to an empty string
}
else // space found
{
// pull off one word form the set
// set value in array
}
// remove the part of the user input that you have used already
// and entered into the array --basically your first line
// increment array variable
} // end while loop
// save the commas in the array
// this would be the comma that was at the end of the string you
// pulled of previously
// increment the array counter
// set the string to the remaining part not used yet
// you have a variable that knows where the comma is
// so use the substring method
} // end while
// Print out the array in proper format using a for loop
// to get through the array
// remember to return the line where you find a comma
// but do not print the comma
for ( ) // loop through the array you filled
{
if ( ) // you find a comma print something
else
// print something else
}// end for loop
} // end the method
} // end the class