2. Write a program that constructs a random telephone number of the form (XXX) XXX-XXXX and outputs a formatted string (parentheses and dashes included) according to the following rules: The first 3 digits may not contain an 8 or 9. The second set of three digits must be larger than 100 and less than 888. a. b. You must construct the desired string (using Random class) and then output it accordingly. Until you are confident in your code, seed the random number generator with 0. For example, (777)-101-0000 is a valid number.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 19RQ
icon
Related questions
Question

Can you give me two ways to do it

Assignment
View Feedb
2. Write a program that constructs a random telephone number of the form (XXX) XXX-XXXX and
outputs a formatted string (parentheses and dashes included) according to the following rules:
The first 3 digits may not contain an 8 or 9.
b. The second set of three digits must be larger than 100 and less than 888.
a.
You must construct the desired string (using Random class) and then output it accordingly. Until
you are confident in your code, seed the random number generator with 0.
For example, (777)–101-0000 is a valid number.
6:2
9/12
67°F Clear
EN
立
Transcribed Image Text:Assignment View Feedb 2. Write a program that constructs a random telephone number of the form (XXX) XXX-XXXX and outputs a formatted string (parentheses and dashes included) according to the following rules: The first 3 digits may not contain an 8 or 9. b. The second set of three digits must be larger than 100 and less than 888. a. You must construct the desired string (using Random class) and then output it accordingly. Until you are confident in your code, seed the random number generator with 0. For example, (777)–101-0000 is a valid number. 6:2 9/12 67°F Clear EN 立
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT