Sei sulla pagina 1di 2

ASSIGNMENT 4

DESCRIPTION

This lab is based on the material studied from week 1 to 10.

This assignment is to be done individually; you are not allowed to work on this assignment with anyone.

ASSIGNMENT SPECIFICATION

This assignment is based on assignment #3 (XYZ Telco Ltd.) attached. Modify your assignment #3 to satisfy
the following specification.
1. Your program should include the following methods:
getCustomerStatus() - This method checks whether a customer has a monthly agreement or not.

getCallTime() -This method ensures that the correct number of minutes and/or seconds are charged if
the customer does not have a monthly plan. Also ensure that the clerks enter up to 59 seconds.
[Seconds entered must not exceed 59 seconds and seconds must be rounded up to the nearest
minute for all subsequent call times after the first 30 seconds.]
From Assignment 3
The billing rate for customers without monthly agreement is CAD $ 0.05 per minute.
The first minute would only be charged after 30 seconds.
After the first minute, the subsequent seconds would round up to the nearest minute.

getCharges() - calculates and returns the total amount to charge the customer. The charges are based on
the flat fee (customers with monthly plan) or on the amount charged by the number of call time
used (customers without monthly plan). If the charges are more than $50, then a flat amount of
$50 is charged.
2. Your program should also include an exception handler that deals with the following:
 Premature exiting when a clerk enters nothing, clicks the ‘X’ button or clicks NO by
mistake should be prevented.
 The program should display a message that informs the clerks of the errors they have
made and should ask them if they want to ‘exit’ or ‘continue’ instead of displaying a
runtime error.
If exit is selected the program should exit gracefully or else allow the program to continue.

SUBMISSION
You must submit the following items on or before the due date specified:
1. Your work must be submitted through SLATE.
2. You must submit the java file(s).

EVALUATION
Your submission will be evaluated based on the following criteria:
Efficient Code: Program uses variables where and only when necessary; program doesn't define variables that are never
used, nor does it use too many variables for unnecessary tasks; program logic is written concisely and is
not cluttered with unnecessary tasks.
Functionality: Program functions according to specifications.
Programming Style: Proper indentation and spacing; use of comments/documentation; all identifiers are descriptive and
valid; variables are defined with appropriate types and converted when required.
Other: Ensure all instructions regarding the submissions and program specifications have been followed.

1 of 2
ASSIGNMENT 3
A new telephone company (XYZ Telco Ltd.) requires a program that allows clerks to calculate and display bills for
customer telephone call charges.

A customer is charged when they make calls; the amount charged is based on the following factors:
 Some customers have a monthly agreement with XYZ Telco so they are charged a fixed monthly rate of CAD
$20.00.
 The billing rate for customers without monthly agreement is CAD $ 0.05 per minute.
o The first minute would only be charged after 30 seconds.
o After the first minute, the subsequent seconds would round up to the nearest minute.

HINT:
 If a customer makes a telephone call for 29 seconds the charge would be free.
 If a customer makes a telephone call for 40 seconds the customer will be charged $0.05.
 If a customer makes a telephone call for 1 minute 20 seconds the customer will be charged $0.10.
 If a customer makes a telephone call for 4 minute 50 seconds the customer will be charged $0.25.

Your program should use an input dialog to retrieve the number of minutes called. If the user enters nothing and clicks
OK, your program should display an error message such as "Invalid data entered, try again", then the input dialog should
be presented to the user again. However, if a user presses Cancel, your program should display a message such as "You
have clicked cancel, program terminating" and the program will exit.

Your program should use a confirm dialog to ask the user whether or not the customer has a monthly agreement.

All literal numeric values in your program must be defined as constants. Be sure to use well-defined and appropriate names
for all of your constants and variables.

Output of your program should be formatted appropriately and should be displayed in a message dialog box. The output
should include:

 The name - XYZ Telco Ltd. Telephone Bill


 The name of the customer
 The number of hours, minutes or seconds called
 The amount charged

2 of 2

Potrebbero piacerti anche