\Java
UsingObjects.java
//********************************************************************
//
// UsingObjects.java
// Program title: UsingObjects
//
//********************************************************************
//
// Program Description and Design Overview:
//
//
// Input Requirements:
//
//
// Output Requirements:
//
//
// Program Preconditions:
//
//
//********************************************************************
import java.util.Random;
import cs1.Keyboard;
import java.text.DecimalFormat;
public class UsingObjects
{
//-----------------------------------------------------------------
// Generate random phone number and prize amount
//-----------------------------------------------------------------
public static void main (String[] args)
{
int AreaCode, First3Dig, Second4Dig;
double Prize;
Random NumMaker=new Random();
System.out.print ("Enter the 3 digit area code: ");
AreaCode = Keyboard.readInt();
First3Dig = Math.abs (NumMaker.nextInt()) % 999 + 100;
Second4Dig = Math.abs (NumMaker.nextInt()) % 9999 + 1000;
System.out.println (AreaCode + "-" + First3Dig + "-" + Second4Dig);
Prize = Math.sqrt ((double)((10000.0 * First3Dig) + Second4Dig));
DecimalFormat fmt = new DecimalFormat ("0.##");
System.out.println ("Your prize is $" + fmt.format(Prize));
} //end main
} // end class UsingObjects