Limited Offer Get 25% off — use code BESTW25
No AI No Plagiarism On-Time Delivery Free Revisions
Claim Now

COMP2741/COMP8741 Application Development

COMP2741/COMP8741 Practical 1, Checkpoints 1-4
Flinders University Page 1 of 5 2019
COMP2741/COMP8741 Application Development (+GE)
Practical 1 – Part a (for week 2) – Checkpoints 1 – 4
Submission Date
Practical 1 (parts a. and b.) in your practical session in Week 4.
A good strategy is to attempt checkpoints from the current practical before attempting
incomplete checkpoints from previous practicals.
The Purpose of Checkpoints, Monitoring Progress and Optimizing Performance
The tasks leading to checkpoints have been designed to improve leaning outcomes by
guiding you to solutions which require the application of techniques and concepts from
course material. They are not designed to be done in isolation.
We expect students to use lecture notes, the text book, workshops and lectures as the basis
for constructing solutions.
The other purpose of the tasks is to allow us to assess your level of understanding and your
ability to apply the knowledge you have acquired. For this reason, checkpoints are not of
equal difficulty. The first 4 or 5 (or 8) have been designed to test basic competence, that is,
to measure performance from just below a pass to Credit level. The last 3 checkpoints
usually require a greater depth of understanding and correspond to the range DN to HD. For
some students it may be possible to complete some of these checkpoints by spending a
large amount of time, however, you should take care not allow completing later checkpoints
to dominate your study time (or other aspects of your life). It is wise to allocate a fixed
amount of time per week for practical work.
Finally, we encourage discussion of the tasks with your peers but plagiarism is dishonest and
detrimental to learning, and can result in severe consequences (please refer to “Academic
Dishonesty” from FLO). To discourage the poor learning outcomes which result from
plagiarism, demonstrators will ask you to explain your solutions unless they have observed
their step by step development and are convinced they are your own work. You will also
find that the ideas which lead to the solution will become clearer through implementation,
testing and reflection.
On FLO in Week 2 you will find a “Practical 1A: Self-Review” quiz that allows you to test for
yourself the completion of the checkpoints 4 and 5.
You need to show your work to a tutor to get the checkpoints
Getting Started
You will be using Java 8 and NetBeans (http://netbeans.org) to develop and run
applications. The application you initially create will not have any visual components. It will
use command line input and output.
Start NetBeans!
COMP2741/COMP8741 Practical 1, Checkpoints 1-4
Flinders University Page 2 of 5 2019
Start of Checkpoint 1
The Task
Create a Java Application in NetBeans, insert some code and run the application.
1. From NetBeans create a new project called Practical1. To do this, in the File menu
select New Project…or click on the “New Project…” icon on the toolbar. In the
resulting wizard window select Java as the category and Java Application as the
project and then click the Next button. In the “Name and Location” window, enter
Practical1 as the Project Name (and optionally change the Project Location), and
then click the Finish button. The NetBeans window should look similar to:
2. Copy and paste the code below into the main method. You may want to use the
“Paste Formatted” from the Edit menu (or Ctrl-Shift-V) to maintain line breaks
Scanner in = new Scanner(System.in);
String msg1, msg2, msg3;
System.out.println(“Enter a line”);
msg1 = in.nextLine();
System.out.println(“Enter another line”);
msg2 = in.nextLine();
System.out.println(“Enter the last line”);
msg3 = in.nextLine();
System.out.println(msg3 + “,” + msg2 + “,” + msg1) ;
3. There will be errors because NetBeans does not know about
the java.util.Scanner class. Right-click in the source code window and select “Fix
Imports” and then click “OK” in the resulting dialogue window.
4. Run the program (e.g. click the “Run Project” button of F6) and type in input as
required. You will need to click in the window that appears below the source window
COMP2741/COMP8741 Practical 1, Checkpoints 1-4
Flinders University Page 3 of 5 2019
to enter the input (the Output window). The Output window should end up
containing something like (the input you should type in is in bold):
Enter a line
Some input
Enter another line
More input
Enter the last line
The end
The end,More input,Some input
5. Convince a demonstrator that your application is correct
This completes Checkpoint 1.
Start of Checkpoint 2
The Task
Add line numbers to the output.
1. Modify the application so that each line of output is numbered, starting from 1. Do
this in such a way that if you inserted another println/nextLine you would not need
to re-number all the lines after that. One way to do this is to use an integer variable
to store the current line number and increase it by one each time you output a line.
After running the program, the output window should look like:
1: Enter a line
Some input
2: Enter another line
More input
3: Enter the last line
The end
The end,More input,Some input
2. Convince a demonstrator that your application is correct.
This completes checkpoint 2.
COMP2741/COMP8741 Practical 1, Checkpoints 1-4
Flinders University Page 4 of 5 2019
Start of Checkpoint 3
The Task
Add a class to the application that stores a line of input and its sequence number.
1. Right-click on the “practical1” package icon and select “New -> Java class…” (that is,
add the class to the same package as the class Main). Change “Class Name” to Line
and then click “Finish”.
2. Add appropriate instance variables (fields) and a constructor to the class so that a
line of text (a String, called text) and a sequence number (an int, called seqNum)
can be stored. These instance variables should be “read only” for other classes. That
is, they should be declared “private” and a “getter” method provided to return the
value. Note that after declaring the instance variable, you can right-click on one of
them, select “Insert code” and then “Getter” to have the getter methods generated
for you.
3. Modify the main method of the class Practical1 so that it stores each line of text
and its sequence number in a Line object, rather than a String object. Modify the
type of variables (msg1 etc.) as required. Note that to print out a line, you will need
to call the getter method. The output of your program should be exactly as before.
The end,More input,Some input
4. Now change the program so that the sequence number is printed with the line. The
final line of output should be:
3: The end,2: More input,1: Some input
Test your code in the self-review quiz on FLO and
convince a tutor that your application is correct.
This completes checkpoint 3.
COMP2741/COMP8741 Practical 1, Checkpoints 1-4
Flinders University Page 5 of 5 2019
Start of Checkpoint 4
The Task
Modify the program so that it uses a loops repeatedly doing:
• prompt for input (using line seqNum and the prompt phrase: “Enter a line”)
• reads the line of input
• stores the line of input in the next position of an array of Line or
an ArrayList of Line.
Once the user enters STOP as input, the loop should terminate and another loop should
print each line in reverse order. For example (the input you should type in is in bold):
1: Enter a line
Some input
2: Enter a line
More input
3: Enter a line
The end
4: Enter a line
STOP
3: The end
2: More input
1: Some input
Hints:
To create an array of Line and add to it, assuming there will be no more than 10 lines, use:
Line[] lineStore = new Line[10];

lineStore[n] = msg; // where msg is an object of type Line

lineStore[0]; // to get the Line object at position 0;
or to create an ArrayList of Line use:
ArrayList<Line> lineStore = new ArrayList<Line>();

lineStore.add(msg); // where msg is an object of type Line

lineStore.get(0); // to get the Line object at position 0
Test your code in the self-review quiz on FLO and
convince a tutor that your application is correct.
This completes checkpoint 4.

The post COMP2741/COMP8741 Application Development appeared first on My Assignment Online.

Plagiarism Free Assignment Help

Expert Help With This Assignment — On Your Terms

Native UK, USA & Australia writers Deadline from 3 hours 100% Plagiarism-Free — Turnitin included Unlimited free revisions Free to submit — compare quotes
Scroll to Top