WRITE A JAVA PROGRAM TO CARRY OUT A SERIES OF OPERATIONS

Qualified Writers
Rated 4.9/5 based on 2480 reviews

100% Plagiarism Free & Custom Written - Tailored to Your Instructions

Overview

This assignment requires you to write a Java program to carry out a series of operations as specified below. The appendix at the back of the assignment specification provides an example of the output required from the final program. The tasks required of your program will require you to demonstrate your understanding of the programming concepts covered in Weeks 1-5 of the course:

• Declaring variables; assigning and testing their values;
• Input and output
• Reading a Class API, and using objects and behaviours of that class
• Decision-making (if and switch statements)
• Loops (for loops, while and/or do..while loops, nested loops)

Timelines and Expectations

Percentage Value of Task: 20%
Due: 4pm Friday of Week 7 – refer to your course description for the date
Minimum time expectation: 10 hours

Learning Outcomes Assessed

The following course learning outcomes are assessed by completing this assessment:
• K1. identify and use the correct syntax of a common programming language;
• K2. recall and use typical programming constructs to design and implement simple software solutions;
• K3. reproduce and adapt commonly used basic algorithms;
• K4. explain the importance of programming style concepts (documentation, mnemonic names, indentation);
• S1. utilise pseudocode and/or algorithms as a major program design technique;
• S2. write and implement a solution algorithm using basic programming constructs;
• S3. demonstrate debugging and testing skills whilst writing code;
• S4. describe program functionality based on analysis of given program code
• A1. develop self-reliance and judgement in adapting algorithms to diverse contexts;
• A2. design and write program solutions to identified problems using accepted design constructs

Assessment Details

Your program must carry out the following tasks, in this order:

• Draw 60 asterisks (*) on the screen followed by a new line character

o This should be accomplished using an appropriate loop construct
o You should be able to do this after Week 4

• Prompt the user to enter a date. This should be achieved by first entering a year, then a month, then a day within that month – these will all be entered as integer values.

o If the user enters a year earlier than 1900 or later than 2100 they should be asked to re-enter a valid year. This process should repeat until they enter a valid value.
o If the user enters a month less than 1 or greater than 12 they should be asked to re-enter a valid month. This process should repeat until they enter a valid value.
o If the user enters a day less than 1 or greater than the number of days in their chosen month, they should be asked to re-enter a valid day. This should repeat until they enter a valid day.

Note: You do not need to consider leap years – you can assume February always has 28 days.

o The sections of program output for year, month and day should be separated by displaying a line of 30 dashes (-) as shown in the sample output at the back of this document. Printing each of these lines should be accomplished using an appropriate loop construct
o You should be able to do this after we have covered while and do..while loops in Week 5

• Once a valid date has been entered by the user you should compare this to the date 1st of March 2016, and print a message stating the outcome of this comparison (that the user’s entered date is before, after or equal to the 1st March 2016).

o You must do this using the java.util.Date class
o Start by reading the online API for java.util.Date, focusing on the constructors and the comparison methods.

 You will notice that Date has been deprecated. This means it has been replaced by another class (in this case GregorianCalendar) and its use is no longer recommended. However it is better suited to the purposes of this assignment, so ignore any warnings which the compiler generates regarding deprecation.

o Use the values entered by the user to instantiate a Date variable

 Carefully read the API documentation to ensure you do this correctly

o Instantiate a second Date variable to represent 1st March 2016
o Use methods from the Date class along with an appropriate decision construct to compare the two Dates, and print out a message – the message should include both dates as formatted by the Date class’ toString() method (as shown in the sample output)
o The relevant material for this will be covered in Weeks 2 and 3

• Draw another 60 asterisks (*) on the screen followed by a new line character

o This should be accomplished using an appropriate loop construct

• For each integer from 5 to 10, print out the ‘hailstone sequence’ which starts with that number.

o A hailstone sequence is a series of numbers produced by starting with any integer value and

repeatedly applying the following rule:

 If the number is even, divide it by 2 (using integer division)
 If the number is odd, multiply it by 3 and add 1
 The sequence ends when it reaches the value of 1

o For example, consider what happens when we start with the value 6.

 6 is even, so we divide by 2 getting 3
 3 is odd so multiply by 3 and add 1, getting 10
 10 is even, so divide by 2 getting 5
 5 is odd so multiply by 3 and add 1 getting 16
 16 is even so divide by 2 getting 8
 8 is even so divide by 2 getting 4
 4 is even so divide by 2 getting 2
 2 is even so divide by 2 getting 1 and ending the sequence

o You can read more about hailstone sequences here: https://plus.maths.org/content/mathematicalmysteries-hailstone-sequences
o You must calculate and print the values in these sequences using nested loops – we will cover these in Week 5

• Draw another 60 asterisks (*) on the screen followed by a new line character
o This should be accomplished using an appropriate loop construct

You should be testing your program as each stage is completed, and again once the program is complete. As well as your program code, you must submit a document detailing the testing which you have performed on your program. This should be formatted according to the University’s guidelines for academic work. This should detail the input data given to the program, why that particular data was chosen, and the expected and actual output from the program. You might choose to structure this as a table as shown below:

Your testing should be thorough, including both valid and invalid data, as well as borderline cases. Your mark for this section will reflect the thoroughness of your testing and the quality of your documentation.

Submission

Your assignment should be completed according to the General Guidelines for Presentation of Academic Work.

The following criteria will be used when marking your assignment:

• successful completion of the required tasks
• quality of code that adheres to the programming standards for the course including:
• comments and documentation
• code layout
• meaningful variable names
• use of constants

You are required to provide documentation, contained in an appropriate file, which includes:

• a front page - indicating your name, a statement of what has been completed and acknowledgement of the names of all people (including other students and people outside of the university) who have assisted you and details on what parts of the assignment that they have assisted you with
• details of test data and evidence that the testing was conducted
• list of references used (APA style); please specify if none have been used.

Using the link provided in Moodle, please upload the following in one zip file:

1. your code (SurnameStudentIdAssign1.java)
2. your report (surnameStudentIDAssign1.docx)

If you encounter any problems in uploading files to moodle please report this to your lecturer or other staff member as soon as possible. It is your responsibility to check that you are submitting the correct version of your files.

NOTE: If you use any resources apart from the course material to complete your assignment you MUST provide an in-text citation within your documentation and/or code, as well as providing a list of references in APA formatting. This includes the use of any websites, online forums, books or text books. If you are unsure of how to do this please ask for help.

Marking Criteria/Rubric

Your program will be marked based on the extent to which it correctly implements the required functionality. The marking scheme will also take into account whether your code is written in a good style, as covered in classes. For example it should be well commented, use meaningful variable names which are consistent with the Java conventions, and be clearly laid out with correct and consistent indenting.

For complete marks your program should also make use of the principles of modularisation as covered in Week 6. It is suggested that you initially develop your program without using methods, as you start this in Weeks 3 to 4 once the relevant material has been covered. Once it is working correctly, make a backup copy which you can submit if your attempt at code modularisation is successful. Then attempt to identify repeated or very similar sections of code, and convert them into methods (using parameters if appropriate).

Price: £109

100% Plagiarism Free & Custom Written - Tailored to Your Instructions