vendredi 23 septembre 2016

JAVA HELP: how to print 20 random phone numbers

HOW DO YOU DO THIS???

PhoneNumber.java Write a program that create and prints 20 RANDOM phone numbers of the form

(XXX) YYY – ZZZZ (XXX) YYY – ZZZZ (XXX) YYY – ZZZZ (XXX) YYY – ZZZZ

Include the parenthesis and the dash in your output.

Do not let an 8 or 9 appear ANYWHERE in the area code (first three digits – XXX). Do not let the area code start with a 0 or 1. There are no other restrictions on this number!

Do not let the second set of three digits, YYY, be greater than 742. Do not let the second set of three digits start with a 0 or 1 either. (In other words, 571 is valid but 175 is not.) There are no other restrictions on this number.

There are no restrictions on the value of the last four digits.

Warning: each digit MUST print in your answer. You need to let the computer pick a random number for you.

Hint: Think this through. Sometimes you have to determine each digit separately, and sometimes you don’t. You may way want to use the DecimalFormat class.

Error Checking: Depending on your algorithm, make sure it is a valid phone number. (571) 555 – 0022 should not read (571) 555 – 22 with the zeros missing.

THANK YOU FOR YOUR TIME!!!




Aucun commentaire:

Enregistrer un commentaire