CSC186 Lab Assignment 1- Basic Programming solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

1. A broadband company, Malaysia SuperBand charges its customers according to the type of
package chosen:
Package Type Internet Quota Price Exceed Quota Usage Charge
Basic (B) 6GB 48 RM0.10 every 1MB
Advanced (A) 10GB 88 RM0.05 every 1MB

a) Write the following function: double calCharge (char, int). This
function will calculate the charge for internet use. It receives the package type and the
amount of data used (in megabyte) as parameters and then calculates and returns the
charge.

Example calculation
Package: B
Internet use: 6800 MB (6.8 GB) – exceeds quota
Charge= Basic charge + Extra charge
= 48 + (6800 – 6000) * 0.20
= 48 + 80
Charge= RM 128
Package B
Internet use: 5500 MB (5.5 GB) – does not exceed quota
Charge= Basic charge
= RM48

a) Write a Java application program to calculate the bill for Malaysia SuperBand’s customers.
It starts by asking for the number of customers. For each customer it will then ask for their
name, their package type and the amount of data used. It then displays the amount to be
paid by the customer. The program will call the function in (a) to perform related tasks.

At the end, the program will display the total amount to be collected from all customers,
the number of customers for each package type and the name of the customer who has to
pay the highest amount.

Sample output screen:
******* Welcome to Malaysia SuperBand ********
Please enter the number of customers: 20
Customer 1
Enter Name: Abdul Rahman
Enter Package type (A – advance, B – Basic): B
Enter Total Internet use (in MB): 6800
Total to be paid by Abdul Rahman: RM 128
Customer 2:
Enter Name: Siti Hayati
Enter Package type (A – advance, B – Basic): A
Enter Total Internet use (in MB): 9000
Total to be paid by Siti Hayati: RM 88

Customer 3:
Enter Name: Muhammad Ali
Enter Package type (A – advance, B – Basic): A
Enter Total Internet use (in MB): 10000
Total to be paid by Muhammad Ali: RM 138
……
……
……
……
Total Charges: RM …..
Number of customers for package A: ……. .
Number of customers for package B: ……. .
The customer with the highest charge is ……………