Recent Question/Assignment

COIT11222 Programming Fundamentals (T2 2019)
Assessment item 1—Java Console Program
Due date: Week 6 T2-19 – Midnight, Friday 30 August 2019 ASSESSMENT
Refer below for complete assessment item 1 requirements
(Assignment One)
Weighting: 20% Length: N/A 1
Objectives
This assessment item relates to the course learning outcomes as in the Unit Profile.
Details
For this assignment, you are required to develop a Java Console Programs to demonstrate you can use Java constructs including input/output via a command line and using GUI dialogs, Java primitive and builtin data types, Java defined objects, selection and looping statements, methods, and various other Java commands. Your program must produce the correct results.
You are only allowed to use techniques which have been covered in the first five weeks of the subject and within the assignment literature, you must use a Scanner object for console input and no advanced data structures like arrays will be used.
What to submit for this assignment
The Java source code:
You will be able to complete the assignment in weekly parts in which you will produce five java source files. (More details below)
Week1.java, Week2.java, Week3.java, Week4.java, and Week5.java.
Once you have completed all of the programs and you are ready to submit, compress all source files into a single zip file for submission, do not include your report in the zip file. Only submit a zip not a rar file
o Ass1.zip
Also submit a report including, how long it took to create (approximately), any problems encountered and screen shots of the output produced. (Use Alt-PrtScrn to capture just the console window or your dialogs and you can paste it into your Word document) You should test every possibility in the program and annotate your test shots. o ReportAss1.docx
You will submit your files by the due date using the “Assignment 1” link on the Moodle course website in the Assessment Block or in the relevant week.
Assignment specification
This assignment will require you to write five small Java programs, do not panic! They will be small programs which will cover the first five weekly topics. Usually students were required to write one largish program to demonstrate the topics for the first five weeks. Students may get themselves into trouble when the first assignment is due as they have not practiced the basics skills necessary to complete the assignment. With the assignment divided into five programs you can complete each exercise as we cover the weekly topics, do not let yourself fall behind. More importantly, this is a progressive way to complete the assignment. Each small program is built on its previous one (you can re-use the previous small program code), except the first one.
General Instructions
Each program must contain a header comment which contains: Your name and student number, the name of the file, the date and a brief description of the purpose of the program:
// Programmer: Eric Gen S01234567
// File: Week1.java
// Date: August 30 2019
// Purpose: COIT11222 assignment one question one T2-19 // Use Scanner object to input data and display them
All programs will be aligned and indented correctly, and contains relevant comments for declarations and statements. All variables and objects will be declared with a meaningful name and use lowercase camel notation:
String customerName;
All code will be contained within a main method except for question five when a user defined method will be created and used, in addition to the main method.
For this assignment you will not worry about checking numeric ranges or data types.
Refer to a Java reference textbook and the course and lecture material (available on the course WEB site) for further information about the Java programming topics required to complete this assignment.
Check the marking guide (last page) to ensure you have completed every task. You need to match all outputs similarly as the sample screenshots shown below.
Distance and Rockhampton students can email questions directly to me, other metro campus students should seek help from your local tutor, you can still contact me if it is urgent, I usually respond to emails very promptly.
Good luck --- Dr. Michael Li COIT11222 unit coordinator T2 2019 m.li@cqu.edu.au
Question one (week one topic) - Writing output to the screen
Once you have written your first “Hello World” program you will be able to complete question one.
Implementation
Create a class called Week1 (file: Week1.java) and within it a main method.
Use the command System.out.println(--) to print out the following shape as a matrix of asterisks.
The first line of asterisks is printed with this command:
System.out.println(-*********-);
You may need to use some graph paper to plot it if you print a complicated pattern with asterisks.
Alternatively, you can print out the first initial of your first and last names as a matrix of asterisks for Week1.java. For example this is my first and last initials printed.
Question two (week two topics) Input of data types and arithmetic expressions
XYZ Courier Service Application Program
This program will allow staff at the XYZ Courier Service to compute the delivery fee of a customer who wants to deliver a parcel. For simplicity, we assume that there is an initial flat delivery rate of $9.50 per kilogram.
This program will prompt for and read in a customer’s name using a Scanner object and prompt to read the customer’s contact phone. The customer name and contact phone will be stored in String objects. Then the program will then output the name in a prompt to input the weight of a parcel that a customer asks to deliver. The weight (kg) of a parcel should be declared as a whole number i.e. an integer.
After all inputs and hitting the Enter button on the keyboard, the program is executed and will display a receipt of delivery. You need to replicate the output similar to the image as below.
Implementation
Create a class called Week2 (file:Week2.java) and within it a main method as per question one.
Import the Scanner class i.e.
import java.util.Scanner;
Within your main create two Scanner objects named inText and inNumber. One for reading text and the other for reading the numbers, it does not really matter here to have separate Scanner objects but there will be problems later when reading a series of text and numbers (see text pg 77).
Create a prompt using System.out.print(); To ask the user for the name of the customer.
Declare a String object customerName to store the customer’s name and use your inText Scanner object and the inbuilt method inText.nextLine();
The customer name is now stored in the String object customerName.
Read the contact phone as the same way you read in the customer name and store it in a String object.
We will need to create a prompt using the customer’s name to ask for the weight of a parcel. Hint: you can join variables and strings using the concatenation operator +
-Enter the weight of - + customerName + -’s parcel: -
Declare an integer variable to store the weight of a parcel and use your inNumber Scanner object and the inbuilt method inNumber.nextInt(); to read the number. Declare a double variable to represent the delivery fee.
The arithmetic expression to calculate the delivery fee is very simple:
fee = weight * RATE
Note: the rate per kilogram must be stored as a constant (use the final keyword). Finally output a receipt of delivery with details as per the sample above.
The delivery fee must be displayed to two decimal points use printf and a format string as follows:
System.out.printf(-$%.2f-, fee);
Question three (week three topics) Decision statements
The management of the XYZ Courier Service would like to promote their business and provide a better service for customers with discounted rates when the weight of a parcel exceeds a particular amount, so it was decided there would be different rates depending on the weight of their parcels. The rates now are set as follows.
2019 XYZ Courier Service Delivery Prices
1-3 kg: $9.50 per kg
From 4 to 8 kg: $7.50 per kg Over 8 kg: $6.00 per kg
Create a class Week3 (file: Week3.java) and a main method and copy your code from question two into the main method of week three main.
After you have read the relevant details of the customer name, contact phone and the weight of a parcel, you will have to create a series of if – else statements to calculate the delivery fee. When you have calculated the delivery fee output a summary as you have done in week two code. Try and devise three arithmetic expressions for the three lengths in terms of the parcel weight so your if-else statement has only three branches. Hints: to calculate the delivery fee for a 4kg parcel, the first 3kg fee plus the 4th kilogram charge (which is in a different rate) should be considered and the formula should be:
fee=3×9.5+(4-3)×7.5
Similarly, the delivery fee for a 10kg parcel should be computed in the following way,
fee=3×9.5+5×7.5+(10-8)×6.0
Your program output needs to match the similar output as shown below for the samples with the parcel weights of 4kg, 5kg and 9kg respectively.
Note: you must use constants for all the numeric literals in the else if statements.
Question four (week four topics) Repetition while and for loops
Create a class Week4 (file:Week4.java) to demonstrate the use of a repetition statement.
Implementation
Using your solution to question three and a while or for loop, repeat the entry of customer name, contact phone and the weight of their parcel N times, where N is the largest digit in your student ID, if your largest digit is less than three then let N = 3. Hint: use N = 3 while testing and submit using the correct N value. In addition, you need to declare 3 counter variables to record the number of parcels with the weight in the specific interval. N will be declared as an integer constant using the final keyword.
You are to print a title before the input of the customer name, contact phone and the weight of parcel (see sample output).
Ensure you are using a separate Scanner objects for reading numbers and text.
When all of the customer name, contact phone and the weight of parcel have been entered, the statistical data including the average weight of all parcels, the all total delivery fee collected, and the numbers of parcels in the specific weight interval should be reported. Please note you do not need to store the data in an advanced structure such as an array. You will need to have an integer variable to add up the weights to calculate the average, and a double variable to add up the delivery fee.

Question five (week five topics) Methods and GUI I/O
Create a class Week5 (file:Week5.java) by using your solution to question four. This question is identical to question four as the program will read in N customer name, contact phone and the weight of their parcels and calculate the delivery fee for each customer, however we are going to create a method and we will be using GUI dialog boxes for our I/O.
Implementation
Methods
You will create a value returning method which will accept the weight of parcel as a parameter.
Use the following method header:
private static double calculateDeliveryFee(int weight)
Copy and paste your “if else” code from week4 for calculating the delivery fee into the body of our new method calculateDeliveryFee. Use the return statement to return the delivery fee.
You can now use your method in the main method loop.
fee = calculateDeliveryFee(weight);
GUI I/O
We will revisit the week two lecture topic using JOptionPane for accepting GUI input and outputting information.
First we will output a welcome message using JOptionPane.showMessageDialog (Replace your console print output).
Next we will replace the Scanner objects by using JOptionPane.showInputDialog
The showInputDialog method will return the string entered into the dialog text field
customerName = JOptionPane.showInputDialog(null, -Prompt-);
Do the same to read in the contact phone.
Next you will need to prompt for the parcel weight, including the customer name.
We receive input from the dialog as a string, in order to convert strings to an integer we need the Integer wrapper class and the parseInt method (text pg 347).
int anInteger =
Integer.parseInt(JOptionPane.showInputDialog(null, -Prompt-));
After reading in and converting the parcel weight to an integer you can use this value to calculate the
delivery fee using your method: fee = calculateDeliveryFee(weight);
Output the summary using: JOptionPane.showMessageDialog(null, -text-)
To format your output in the text argument in showMessageDialog you can use:
String.format(-Format string-,args)
See the example below for using place holders to format strings, integers and doubles.
String.format(-%s %s %d $%.2f-, customerName, contactPhone, weight,fee)
%s is for a string.
%d is for an integer.
%.2f is for a floating point number (including double) formatted to two decimal places.
The will produce a newline and you will need to add extra text to the format string to match the output above.
When the N customers have been entered, you will report the maximum and minimum values of delivery fee, as well as the corresponding customer names. You need to declare a double variable for maximum delivery fee and another String type variable for the corresponding customer name. Then inside the for loop, use an if statement to compare the assumed maximum delivery fee and current delivery fee. You can use the same way to deal with minimum delivery fee and the corresponding customer’s name. The following image shows a sample result with the maximum and minimum delivery fees.
Marking Scheme
Total number of marks – 20
1 Code in general
Code is indented and aligned correctly, layout including vertical white space is good
1
Code has header comment which includes student name, student ID, date, file name and purpose of the class
0.5
Code is fully commented including all variables 0.75
Variables have meaningful names and use camel notation 0.75
Variables are the correct type 0.5
2 Question one
Output as per specification 1
3 Question two
Strings are read correctly using Scanner object 0.5
The integer is read correctly using a Scanner object 0.5
The delivery fee is computed and displayed correctly to two decimal places
0.5
Output is formatted correctly (matches sample output) 0.5
4 Question three
If else statements are correct and constants are used 1.25
Correct delivery fee is calculated and displayed correctly to two decimal 1.25
Output is formatted correctly (matches sample output) 0.5
5 Question four
Constant N used equal to highest digit in student ID 0.5
N customer names, contact phones and weights are read in a loop 1
Program title -XYZ Courier Service Application Program- printed 0.25
Delivery fees printed for all customers 0.25
Average weight of parcels and all total delivery fee collected are calculated and printed correctly to two decimal places
1
Simple statistics results including the numbers of parcel in the specific weight interval are correctly recorded and displayed 1
Output is formatted correctly (matches sample output) 0.5
6 Question five
Method implementation (uses a parameter) 0.5
Dollar (double) value returned from method correctly 0.25
Method call correct (uses an argument) 0.5
GUI welcome message 0.25
Strings are read correctly from GUI Input dialogs 0.25
The parcel weight read correctly from GUI Input dialog and converted to an integer
0.5
N customer names, contact phones and weights are read in a loop 0.25
Maximum and minimum values of delivery fee are calculated and printed correctly to two decimal places.
1
Dialogs appear as per specification (matches sample output) 0.5
7 General
Correct files submitted including types and names (zip and Word) 0.5
Only techniques covered during weeks 1-5 and specification are used 0.5
8 Report
Report presentation and comments including how long the programs took to create and any problems encountered
0.5
Screen shots of testing and annotations 0.5
COIT11222, 2019 Term Two - Page 12 of 13
COIT11222, 2019 Term Two - Page 13 of 13

Looking for answers ?


Recent Questions

Assessment Task 1: Change management planTASK SUMMARY:There are four parts to this assessment:? Part A – You are required to review the case study provided below then conduct and analyse research on change...Assessment Task 1: Written QuestionsTask summaryThis is an open book test, to be completed in the classroom.A time limit of 1.5 hours to answer the questions is provided.You need to answer all of the written...StudentAssessment Guide:BSBRSK501 Manage risk Copyright 2019? Australian College of Business IntelligenceAll rights reservedVersion: 19.0Date Modified: October 2019No part of this publication may be reproduced,...StudentAssessment Guide:BSBWRK520 Manage employee relations Copyright 2019? Australian College of Business IntelligenceAll rights reservedVersion: 19.0Date Modified: September 2019No part of this publication...Context:The assessment suite in this subject is designed to provide students with a framework to understand organisational behavior and the dynamics of the business environment. The assessment suite aims...Assessment BriefProgram Bachelor of Applied Social ScienceSubject Applied Counselling Practice 3Subject code COU204AName of assessment Assessment 3: Skills demonstration + reflective reportLength Skills...Unit Details BSBMGT615 Contribute to Organisation developmentEtS0NIGT615 Student Assessment V2.0 August 2019Page 1 of 16Scanned by CamScannerAssessment Task 3PracticalDemonstrationAssessment MethodsAssignmentProjectAssessment...Show All Questions