Ask Java Expert


Home >> Java

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.

  • • 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)

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 construct

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

• 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

• 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)

• 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:

352_Untitled.png

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M91828931
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As