This is the final version:
// PhoneBill.java
//
//
// Copyright 2004 Reynold DeMarco Jr
/**
* class for computing Phone Bills
* using LinearEquation objects.
*
* @version 1
*/
public class PhoneBill
{
public static void main ( String[] args )
{
//declare doubles
double a_new, b_new, bill, end ;
//create a Terminal object
Terminal pb = new Terminal();
//get user input parameters
b_new = pb.readDouble("Basic rate (in dollars): ");
a_new = pb.readDouble("Cost per message unit (in cents): ");
//create a LinearEquation object
LinearEquation showBill = new LinearEquation(a_new*0.01,
b_new);
//last user input parameter for computation
bill = pb.readDouble("Number of message units: ");
//have the LinearEquation object compute the bill
pb.println("Phone bill is: $" + showBill.compute(bill) );
//use LinearEquation objects to get units
LinearEquation changeToUnits = new LinearEquation(-1.0, 0.0);
LinearEquation showEnd = new LinearEquation(100/a_new, 0.0);
//get user input for second computation
end = pb.readInt("Amount willing to spend (in dollars): ") +
changeToUnits.compute(b_new);
//have the LinearEquation object compute
pb.println("Maximum number of message units: " +
showEnd.compute(end));
}
}