Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: phone number generator1

  1. #1
    Junior Member yuli's Avatar
    Join Date
    Nov 2013
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: phone number generator1

    Please keep all discussion to your other post.
    http://www.javaprogrammingforums.com...generator.html
    Thread locked

Similar Threads

  1. phone number generator
    By yuli in forum What's Wrong With My Code?
    Replies: 18
    Last Post: November 4th, 2013, 05:36 PM
  2. Call to any phone number from a webpage
    By yaatri in forum Web Frameworks
    Replies: 0
    Last Post: April 10th, 2012, 12:41 PM
  3. need help with phone number program for homework
    By stevolabo in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 23rd, 2012, 07:34 PM
  4. HELP! Server side validation for phone number
    By LexenZ in forum JavaServer Pages: JSP & JSTL
    Replies: 5
    Last Post: June 19th, 2011, 10:29 AM