Java Reference
In-Depth Information
Because the program will ask the user to input the customer account number,
customer code, number of premium channels, and number of basic service connec-
tions, you need variables to store all of this information. Also, because the program
will calculate the billing amount, you need a variable to store the billing amount.
Thus, the program needs at least the following variables to compute and print the bill:
VARIABLES
int accountNumber; //variable to store customer's
//account number
char customerType; //variable to store customer code
int noOfPremChannels; //variable to store number
//of premium channels to which
//the customer subscribes
int noOfBasicServConn; //variable to store number of
//basic service connections
//to which the customer subscribes
4
double amountDue;
//variable to store the billing amount
As you can see, the bill-processing fees, the cost of a basic service connection, and the
cost of a premium channel are fixed; these values are needed to compute the bill.
Although these values are constants in the program, they do change periodically. To
simplify the process of modifying the program later, instead of using these values
directly in the program, you should declare them as named constants. Based on the
problem analysis, you need to declare the following named constants:
NAMED
CONSTANTS
//Named constants - residential customers
static final double R_BILL_PROC_FEE = 4.50;
static final double R_BASIC_SERV_COST = 20.50;
static final double R_COST_PREM_CHANNEL = 7.50;
//Named constants - business customers
static final double B_BILL_PROC_FEE = 15.00;
static final double B_BASIC_SERV_COST = 75.00;
static final double B_BASIC_CONN_COST = 5.00;
static final double B_COST_PREM_CHANNEL = 50.00;
The program uses a number of formulas to compute the billing amount. To compute
the residential bill, you need to know only the number of premium channels to
which the user subscribes. The following statement calculates the billing amount for a
residential customer:
amountDue = R_BILL_PROC_FEE + R_BASIC_SERV_COST +
noOfPremChannels * R_COST_PREM_CHANNEL;
To compute the business bill, you need to know the number of basic service
connections and the number of premium channels to which the user subscribes. If
the number of basic service connections is less than or equal to 10 , the cost of the
basic service connections is fixed. If the number of basic service connections exceeds
FORMULAS
Search WWH ::




Custom Search