PhoneNumbers - DecimalFormat fmt = new...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // PhoneNumbers.java Author: Lewis and Loftus // // Solution to Programming Project 2.13 //******************************************************************** / import java.util.Scanner; import java.text.DecimalFormat; i public class PhoneNumbers { //----------------------------------------------------------------- // Produces a random phone number with various constraints. //----------------------------------------------------------------- public static void main (String[] args)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { DecimalFormat fmt = new DecimalFormat ("###"); String result = ""; // none of the first three digits is higher than 7 result += (int) (Math.random() * 8); result += (int) (Math.random() * 8); result += (int) (Math.random() * 8); result += "-"; // then next set of digits cannot be greater than 742 result += (int) (Math.random() * 643) + 100; result += "-"; result += (int) (Math.random() * 8888) + 1000; System.out.println ("A random phone number: " + result); } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online