# phone number generator1

• November 4th, 2013, 03:25 PM
yuli
phone number generator1
/*juliana Vargas
programing
10/29/2013
*/
import java.util.Random;
public class RandomPhoneNumber
{
public static void main (String[]args)
{Random generator = new Random();

/*write down the RandomNumber AreaCode1 AreaCode2 AreaCode3;
*choose the first 3
*choose the second 3
*choose the last four
*combine them
*/

int RandomNumber =0;
int exchange;
int LastFour =0;
int number;
int num1 = 0;

System.out.println(" Enter the amount of numbers you want to receive: ");
number = generator.nextInt();

num1 = (int)(1+Math.random()*3);
if (num1 == 1)
num1 = 281;
System.out.printf(""+num1);
if (num1 == 2)
num1 = 713;
System.out.printf(""+num1);
if (num1 == 3)
num1 = 832;
System.out.printf(""+num1);

RandomNumber = generator.nextInt();

exchange =( int )(237 + Math.random() * 517);
RandomNumber = generator.nextInt();

while (LastFour == 1212)
LastFour = (int) (0 + Math.random() * 9999);
RandomNumber = generator.nextInt();

System.out.println( "Phone numbers that resulted " +"("+num1+")" +exchange +"-"+LastFour);

}
}

--- Update ---

it wont let me input the amount of numbers I want .... and for the last 4 numbers it will always show a 0.. what is wrong
• November 4th, 2013, 03:37 PM
copeg
Re: phone number generator1