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: a. 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. 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.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

Java

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:
a. 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.
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.
Transcribed Image Text: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: a. 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. 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.
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning