View the step-by-step solution to:

# I am to create a random phone number generator with specific restrictions, as shown in the commented section in the beginning, and I have everything...

I am to create a random phone number generator with specific restrictions, as shown in the commented section in the beginning, and I have everything but the first three digits working. I can get them to work separately, but I am not supposed to do it that way...the following is my most recent attempt.

/* Do not let the first three digits contain an 8 or 9. Make sure that the second set of 3 digits is not greater than 742. Do not determine each digit seperately. */

class PhoneNumber
{
public static void main(String args[])
{
for(int i = 1; i == 10; i++);
{
int z = 0;
for(int i = 0; i == 3; i++);
{
z = (int) (Math.random()*7) + 1;
if(z <= (int) 7)
{
System.out.println(z);
}
if(z == (int) 8)
{
z--;
}
if(z == (int) 9)
{
z--;
z--;
}
System.out.println(z+""+z+""+z);
}

int x = 0;
for(int i = 1; i <= 1; i++);
{
x = (int) (Math.random()*643) + 100;
}

int c = 0;
for(int i = 1; i <= 1; i++);
{
c = (int) (Math.random()*8999) + 1000;
}
System.out.println(z+""+z+""+z+"-"+x+"-"+c);
}
}
}
}

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents