Get Cheapest Assignment in Australia, UK, US, UAE, Canada and NZ Order Now

301038 PP


Due at Midnight Fri Sep 10 2021
 	Released on 2/8/2021, last modified and finalised on xx


  1. Over the semester, you will be working in a group of two, but this 1st assignment is an individual one.
  2. This assignment 1 is worth 20% of the total marks for this Unit, and it is composed mainly of the questions taken directly from the covered chapters of the prescribed textbook.
  3. Quality of the work, including such as proper program design and coding style and documentation/comments, will also be a major factor of consideration for the top grades.
It is best that the assignment questions below corresponding to each chapter in the textbook be worked on and solved during the lab practical for that chapter, or in the next few days immediately afterwards.  
301038 PP
301038 PP


  1. (PP 1.10, p.82) (2 marks) Write a program that displays the word “HI” in large block letters. Make each large letter out of the other character as shown below. Use a single System.out.print()

statement to generate the whole display, and do not print any unneeded characters. (That is, don’t make any character string longer than it has to be.)

  • (PP 2.10 p.135) (3 marks) Write a program that determines the value of the coins in a jar and prints the total in (whole) dollars and (the remaining) cents. Read with suitable prompts the integer values that represent the number of quarters, dimes, nickels, and pennies.
  • (PP 4.6, p.229) (4 marks) Write a class called Shelf that contains instance data that represents the length, breadth, and capacity of the shelf. Also include a boolean variable called occupied as instance data that represents whether the shelf is occupied or not. Define the Shelf constructor to

accept and initialize the height, width, and capacity of the shelf (height/width here in the textbook

should refer to length/breadth). Each newly created Shelf is vacant (the constructor should initialize occupied to false). Include getter and setter methods for all instance data. Include a toString method that returns a one-line description of the shelf. Create a driver class called ShelfCheck,

whose main method instantiates and updates several Shelf objects. The main method should also contain your code to illustrate the use of all the methods defined in Shelf.

  • (2 marks) Use a while loop and a for loop to calculate separately the following sum

cos(1 + 2/(3*5)) + cos(2 + 3/(4*6)) + cos(3 + 4/(5*7))

+ … + cos(96 + 97/(98*100))

Store the results in 2 separate variables and display their values before the program ends.

  • (4 marks) Write a simple menu-drive program so that you can change the input text and have it displayed on the top of the menu,

display the input text in the reverse order of the character positions, display the most used character/s used in the input text.

When you start the menu program, it should display a simple menu, similar to something like

where your own name should replace the text “Student’s Name”. If you enter a at the menu’s input prompt, then the corresponding menu item Input a new line of text will be executed. Likewise for the other menu items. For anything else you enter at the menu input prompt, a suitable warning message will be displayed before redisplaying the whole menu.

  • (PP 4.9, p.229, modified)

(3 marks) Using the Die class defined in Chapter 4, write a class called TwoDice, composed of two Die objects. Include methods to set and get the individual die values, a method to roll the dice, and a method that returns the current sum of the two die values. Include a static main method in TwoDice so that it can instantiate and use a TwoDice object to illustrate all the features in the class.

(2 marks) Similar to the above question, write a class called MultiDice, composed of any number of Die objects. Use ArrayList to keep all the Die objects, and use a constructor to

construct such a list of objects. Include a method that displays all the die values, and another method that calculates the sum of all the die values. Write a driver/main method to create a list of 10 dice (of random die values), and then display their respective values and the sum of their values.


The submitted Java programs should be directly compilable and runable without the use of any Java IDE (such as Netbeans or Eclipse), although students are free to develop their project system with any Java IDE they may choose. That is, your submitted Java code should be directly compilable via javac in the subdirectory where your Java program is kept, and your Java programs should be compilable and runnable under the JDK installed on the same lab/s (currently at version 1.8, or more precisely, 1.8.0_261, the last subversion of ver 1.8) to which this unit is scheduled. Uncompilable Java programs may lead to an automatic loss of 50% of the respective total marks.

The submission should also contain a Microsoft Word document that, question by question, list the Java source code (not as screen shots) as well as the screen shots of the corresponding execution result. Please note that the screen shots must be easily readable when printed out.

Zip (don’t use the rar compression format) all the relevant files into a single zip file, and then upload it via the submit button on the unit website. 1 mark may be deducted if the submission is done via the rar compression. It’s each student’s responsibility to keep the submission receipt which will be

automatically generated after each successful submission.

Leave a Reply

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