I figured it out. I thought I would share the solution. I added commented asterics lines to show the beginning and end of the code blocks I added:
import java.util.*;
public class TelephoneConverter
{
static Scanner console = new Scanner(System.in);
public static void main(String[] args)
{
String inputStr, lowerCase, preStr, postStr;
int hyphenIndex, i = 0, j = 0, k = 0, jump = 1, length, preLength, postLength, num = 0;
char character = ' ';
System.out.println("Enter the phone number as a phrase, including the hyphen: ");
inputStr = console.nextLine();
lowerCase = inputStr.toLowerCase();
hyphenIndex = lowerCase.indexOf("-");
length = lowerCase.length();
preStr = lowerCase.substring(0, hyphenIndex);
postStr = lowerCase.substring(hyphenIndex + 1, length);
preLength = preStr.length();
postLength = postStr.length();
System.out.print("Your number is: ");
if((preLength == 3) && (preStr.charAt(1) == ' ')) //**************************************************
{
System.out.print(ReturnsNum(preStr.charAt(0)));
System.out.print(ReturnsNum(preStr.charAt(2)));
System.out.print(ReturnsNum(postStr.charAt(0)));
System.out.print("-");
i = 4;
j = 1;
while(i > 0 )
{
character = postStr.charAt(j);
j++;
i--;
if(ReturnsNum(character) == 1)
{
System.out.print("");
j++;
i++;
}
else
{
System.out.print(ReturnsNum(character));
} //***********************************************
}
}
if((preLength == 3) && (preStr.charAt(1) != ' '))
{
i = preLength;
while(i > 0)
{
if(num == 1)
{
j++;
i--;
}
character = preStr.charAt(j);
i--;
j++;
System.out.print(ReturnsNum(character));
}
System.out.print("-");
j = 0;
i = 4;
while(i > 0)
{
character = postStr.charAt(j);
i--;
j++;
if(ReturnsNum(character) == 1) //*************************************************
{
System.out.print("");
j++;
i++;
}
else
{
System.out.print(ReturnsNum(character));
} //***********************************************
}
}
else if(preLength > 3)
{
i = 3;
while(i > 0)
{
character = preStr.charAt(j);
i--;
j++;
System.out.print(ReturnsNum(character));
}
System.out.print("-");
i = preLength - 3;
j = 3;
while(i > 0)
{
character = preStr.charAt(j);
i--;
j++;
System.out.print(ReturnsNum(character));
}
i = 7 - preLength;
j = 0;
while(i > 0)
{
character = postStr.charAt(j);
i--;
j++;
if(ReturnsNum(character) == 1) //********************************************
{
System.out.print("");
j++;
i++;
}
else
{
System.out.print(ReturnsNum(character));
} //********************************************
}
}
else if(preLength < 3)
{
j = 0;
i = preLength;
while(i > 0)
{
character = preStr.charAt(j);
i--;
j++;
System.out.print(ReturnsNum(character));
}
j = 0;
i = 3 - preLength;
while(i > 0)
{
character = postStr.charAt(j);
i--;
j++;
if(ReturnsNum(character) ==1) //******************************************
{
System.out.print("");
j++;
i++;
}
else
{
System.out.print(ReturnsNum(character));
} //****************************************
}
System.out.print("-");
j = 0;
i = 4;
while(i > 0)
{
character = postStr.charAt(j);
i--;
j++;
if(ReturnsNum(character) == 1) //**********************************************
{
System.out.print("");
j++;
i++;
}
else
{
System.out.print(ReturnsNum(character));
} //******************************************
}
}
}
public static int ReturnsNum(char character)
{
int num = 0;
switch(character)
{
case ' ':
num = 1;
break;
case 'a':
case 'b':
case 'c':
num = 2;
break;
case 'd':
case 'e':
case 'f':
num = 3;
break;
case 'g':
case 'h':
case 'i':
num = 4;
break;
case 'j':
case 'k':
case 'l':
num = 5;
break;
case 'm':
case 'n':
case 'o':
num = 6;
break;
case 'p':
case 'q':
case 'r':
case 's':
num = 7;
break;
case 't':
case 'u':
case 'v':
num = 8;
break;
case 'w':
case 'x':
case 'y':
case 'z':
num = 9;
break;
}
return num;
}
}