CST8110 – Introduction to Programming (Solution)

$ 24.99
Category:

Description

Assignment #2 – Using interacting classes – Composition

Problem Description:
Write and test the program code in Java to solve the following problem:

• This problem will simulate producing a very basic invoice for a Telecom company (ie a company that provides simple cell phone service). Devise a name for your company, and use it in the first line of display from the program. (see example)
• The invoice will only handle one month bill for one client. We will call this class Invoice.

• The program should ask for the total number of daytime minutes of cell service to be purchased for the month (evening/weekends and texting are free for now).
• The program should calculate the invoice amount – which will be a flat rate of $5.00 per month plus the number of minutes purchased in the month multiplied by 2 cent per minute.
• Your code needs to format the output – specifically money amounts to two decimal places, etc.. Use either the DecimalFormat class or the printf() statement.

• Your method main should be in class called Assignment2.

Suggested design for OurDate class (from lab3):
• Three private integer fields to store year, month and day
• Methods:
o Constructor – using three integers to set initial values for year, month and day
o calcDays()– returns an int which is the number of days from Jan 1, 1900 – use 30 days per month for now,  360 days per year.

Suggested design for Invoice class :
• Five private float or double fields to store minutesPurchased, invoiceAmount, interest, tax, totalAmount
• Two private OurDate fields to store todayDate and invoiceDate
• Methods:
o Constructor – default amounts to 0
o displayInvoice – display the invoice

************************Opportunity for Bonus Marks******************************
• Your code needs to worry if the user inputs an invalid value for the inputs (example negative number or outside an appropriate range). You do not need to worry about a user entering characters just yet – this would require a little bit more coding.
• Worth 5 extra marks but ONLY if all your other assignment features, as specified in the marking guide, are perfect – this assignment is potentially worth 25/20 marks

******************************************************************************************

Sample Output #1: (blue indicate user entered information)
Welcome to the Crane Telecom Company Billing System Enter the number of minutes you wish to purchase: 100
Enter a valid year: 2014
Enter the month: 3
Enter the day: 6
Enter a valid year: 2014
Enter the month: 3
Enter the day: 2

Invoice amount : $7.00
Tax : $0.91
Interest : $0.00
TOTAL : $7.91
Sample Output #2: (blue indicate user entered information)
Welcome to the Crane Telecom Company Billing System Enter the number of minutes you wish to purchase: 1050
Enter a valid year: 2014
Enter the month: 3
Enter a valid year: 2014
Enter the month: 1
Enter the day: 1

Invoice amount : $26.00
Tax : $3.38
Interest : $2.60
TOTAL : $31.98

Submission Requirements:
• You must create a .zip file that contains ONLY the following:
o Your program code – .java files – (with your name, section, lab teacher listed in comments in the header of the program)
o A document created with either Notepad, Wordpad or Word named Assign2.docx or Assign2.txt with your test plan – note this should contain your name, section and lab teacher listed at the top.
• The .zip file must have the following as it’s name o Your last name, your first name, the word assign and the assign number …. Example RosenblumHowardAssign2.zip
• Marks will be given for correct submission (ie marks will be deducted for incorrect submission!

Reviews

There are no reviews yet.

Be the first to review “CST8110 – Introduction to Programming (Solution)”

Your email address will not be published. Required fields are marked *