Cable Company Billing in Java Application
Submitted by GeePee on Tuesday, May 26, 2015 - 21:11.
This Java program application calculates and prints a customer’s bill for a local cable company. The program process two types of customers: Residential and Business. . I will be using the JCreator IDE in developing the program.
To start in this tutorial, first open the JCreator IDE, click new and paste the following code.
Sample run:
- import java.util.*;
- public class CableCompanyBilling
- {
- 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;
- 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;
- {
- int accountNumber;
- char customerType;
- int noOfPremChannels;
- int noOfBasicServConn;
- double amountDue;
- accountNumber = console.nextInt();
- + "R or (Residential), "
- + "B or (Business): " );
- customerType = console.next().charAt(0);
- switch (customerType)
- {
- case 'r':
- case 'R':
- noOfPremChannels = console.nextInt();
- amountDue = R_BILL_PROC_FEE + R_BASIC_SERV_COST + noOfPremChannels * R_COST_PREM_CHANNEL;
- break;
- case 'b':
- case 'B':
- noOfBasicServConn = console.nextInt();
- noOfPremChannels = console.nextInt();
- if (noOfBasicServConn <= 10)
- amountDue = B_BILL_PROC_FEE + B_BASIC_SERV_COST + noOfPremChannels * B_COST_PREM_CHANNEL;
- else
- amountDue = B_BILL_PROC_FEE + B_BASIC_SERV_COST + (noOfBasicServConn - 10) *
- B_BASIC_CONN_COST + noOfPremChannels * B_COST_PREM_CHANNEL;
- break;
- default:
- }
- }
- }
This program computes cable bill
Enter the account number: 23456
Enter the customer type: R or (Residential), B or (Business): R
Enter the number of premium channels: 40
Account Number = 23456
Amount Due + 325.0
The algorithm of the program:
The purpose of this program is to calculate and print the billing amount.
To calculate the billing amount, you need to know the customer for whom the billing amount is calculated and the number of premium channels to which the customer subscribes.
Prompts the user for the account number and customer type.
Determine the number of premium channels and basic service connections, compute the bill, and print the bill based on the customer type.
If the customer type is R or r, prompts the user for the number of premium channels, computes the bill and print the bill.
If the customer type is B or b, prompt the user for the number of basic service connections and number of premium channels, computes the bill and print the bill.
Comments
Add new comment
- Add new comment
- 1364 views