Unit 41 Programming in Java Assignment Sample

Home
breadCrumb image
Solution
breadCrumb image
Unit 41 Programming in Java Assignment Sample
programming in Java Assignment Sample
Unit 41 Programming in Java Assignment Sample

LO1: Understand the principles of programming in Java

1.1 Discuss the principles, characteristics and features of programming in java

Solution:
Java language high level language. A language is known as high level language if it provides human readable syntaxes for programming where as low level languages provides machine instructions which are not user friendly. Java uses English language for programming commands.

Basic characteristics of Java Language:

  • Object Oriented Programming: If our problem is solved in terms of classes and objects then it is known as Object Oriented Programing. In object oriented programming every problem is solved in terms of classes and objects. Features of object oriented programming:
    Encapsulation: Encapsulation means packaging all class data and code into a class which prevent it for outside access and misuse.
    Inheritance: If a class is derived from another class then it is known as Inheritance. Using inheritance we can extend features of a class.
    Polymorphism: Polymorphism means one name many forms. Using polymorphism we can define different functionality for a class inheritance hierarchy with same name.
  • Distributed: Java provides distributed applications functionality which enables us to run different parts of an application on different machines. Java RMI (Remote method invocation) and EJB (Enterprise Java Beans) enables us to create distributed applications.
  • Robust: Robust means strong. Java provides strong memory server management. Java doesn’t provide pointers to avoid security problems. It also provides automatic garbage collection and robust error & type checking.

Advantages and Disadvantages of JDK system with an IDE like Netbeans:
Advantages of using an IDE:

  • IDEs provide syntax highlighting to users.
  • IDEs provide automatic indentation for code blocks.
  • IDEs provide line numbers to its users.
  • IDEs provide auto code completion.
  • IDEs provide auto code generation for inherited members.
  • IDEs provide code debugging functionality and making check points to find out errors.
  • Some IDEs provide GUI builder to build application for rapid application development
    Disadvantages of using an IDE:
  • IDEs prevent novice programmers from basic knowledge of language.
  • IDEs generate generalized code which is not optimized for all applications.
  • IDEs show compatibility issues with projects of other IDEs.

1.2 critically evaluate the environmental flexibility of programming in Java

Solution:
Platform Independence

Java language is platform independent. First of all its source code gets compiled into a class file which is also known as Byte Code. Byte code contains machine instructions for the operating system. This generated byte code is same for all platforms id Windows, Linux, Mac etc. Byte code is evaluated and interpreted by Java Virtual Machine (JVM).  JVM is platform dependent but it is available for all platforms.
Thus byte code instructions and JVM together makes Java platform independent.
Java for Mobile Applications (Java ME)
Java ME stands for Java Micro Edition. It enables us to develop applications for small devices like pages, set-top boxes, mobile phones etc. Java ME is specifically designed for battery operated devices with small memory and processing speed. Java ME provides a special JVM for micro devices which is known as KVM. It is a cut down version of standard JVM and optimized for working in very small amount of memory (256 KB)
Embedded Hardware Programming in Java
Java provides an extension of Micro Edition API which is suitable for embedded applications and known as Java ME Embedded. It enables users to develop highly secure, robust, scalable and functional applications for embedded devices like cameras, flight control systems and ATM machines.

LO2: Be able to design Java Solutions

2.1 Design a java programming solution for to a given problem.

Solution
My java programming solution is as follows:
Possible Inputs:
width of room:
It is required to calculate area of the room.
Length of room: It is required to calculate area of the room.
Possible Outputs:
Area:
The application will display final area on which all work has to be done.
Time: The application will display total time required to complete the work.
Cost: The application will display final cost for the work.

Possible User Interface:

Unit 41 Programming in Java Assignment Sample 

2.2 Explain the components and data file structure required to implement a given design.
 

Solution:
Variable Names used in the application

Variable Name

Data-Type

Java Statement

roomLength

double

private double roomLength = 0.0;

roomBreadth

double

private double roomBreadth = 0.0;

roomArea

double

private double roomArea = 0.0;

estimatedTime

int

private intestimatedTime = 0;

cost

double

private double cost = 0.0;

robertsWage

double

private double robertsWage = 0.0;

woodCost

double

private double woodCost = 0.0;

Constants used in the application

Constant Name

Data-Type

Java Statement

avgRateOfInstallation

byte

private final byte avgRateOfInstallation = 3;

assistantPrice

float

private final float assistantPrice = 10.25f;

priceOfWood

float

private final float priceOfWood = 19.95f;

robertCharge

float

private final float robertsCharge = 85.0f;

Pseudo Code: Pseudo code is step by step instruction set to solve a problem. It specify basic logic which is to be implemented in order to solve a problem. Functionality of this application “Wage Calculator” can be achieved by following these steps:

  • Application Start: User starts the application.
  • Read number of rooms on which process has to be applied.
  • Read length of room and breadth of roomfrom user.
  • Calculate the area of room by multiplying room length and breadth ( (area = length*breadth).
  • Repeat from Step-3 until area of all rooms has calculated.
  • Calculate total area of all rooms by adding individual room area.
  • Calculate the time required for installation (in hours), using the area of the room and rate of installation (3m2/hour).
  • Calculate cost of assistants by multiplying total time and salary (€10.25/hour).
  • Calculate Robert’s Wage by multiplying total time and Robert’s charges (.€85.00/week).
  • Calculate the cost of wood by multiplying area and price of wood (€19.95/m2)
  • Finally calculate totalwage = (assistants cost) + (Roberts charges) + (cost of wood).
  • If wage>€300 then payment mode can be debit and credit only
  • If payment mode is debit then final wage = wage +€0.50.
  • If payment mode is credit then final wage = wage + 2% of wage.
  • Otherwise final wage = wage.
  • End of program.

Flowchart

Unit 41 Programming in Java Assignment Sample 

Need help?

Get Complete Solution From Best Locus Assignment Experts.

Place an order

LO3: Be able to implement Java Solutions

3.1 Implement a java programming solution based on a prepared design.

Solution:
Java Programming Solution

Following is screen shots of java code in net beans editor:

Unit 41 programming in Java Assignment Sample

Unit 41 Programming in Java Assignment sample

Unit 41 Programming in Java Assignment Sample

3.2 Define relationships between objects to implement design requirements

Solution:

Unit 41 Programming in Java Assignment Sample

3.3 Implement object behaviors using control structures to meet the design algorithms
 

Solution:
Following behaviors are defined to calculate wages for the application.

Unit 41 Programming in Java Assignment Sample

3.4 Identify and implement opportunities for error handling and reporting

Solution:
Following screens shows error and exception handling in the application

  • Error Handling for empty string

Unit 41 programming in Java Assignment Sample

  • Error Handling for invalid value
    Unit 41 Programming in Java Assignment Sample

3.5 Make effective use of an Integrated web Development Environment (IDE) including code and screen templates.
 

Solution:
All screens of the application are designed in Netbeans IDE using Swing editor. Application interface is as follows.

 

Unit 41 programming in Java Assignment sample
Figure: Initial screen to read number of rooms.

Unit 41 programming in Java Assignment Sample

Figure: Screen to read room details from user.

Unit 41 Programming in Java Assignment Sample

Figure: Screen after filling the data.

Unit 41 Programming in Java Assignment Sample

Figure: Confirmation message before moving to next screen.

Unit 41 Programming in Java Assignment Sample

Figure: Error Message if user leaves blank fields and tries to move to next screen.

Unit 41 Programming in Java Assignment Sample

Figure: Confirmation before final submission

Unit 41 programming in Java Assignment Sample

Figure: Final result with debit card option.

Unit 41 programming in Assignment Sample

Figure: Final result with credit card option.

LO4. Be able to test and document java solutions

4.1 Critically review and test a java programming solution


Solution:
This application “Wage Calculator” is critically reviewed and tested and results are as follows:

  • Review for User Interface: User Interface of this application is very simple and friendly. All input fields have proper labels.
  • Review for error handling: This application properly handles all input errors and shows appropriate message to its users.

4.2 Analyse actual test results against expected test results to identify discrepancies.


Solution:
Test results against expected test results are as follows:

Test Case

Expected Result

Actual Results

Input Checking and Validation

Application must display error message for invalid input.

Application is displaying error message for every wrong input.

Floating Point Calculation

While calculating cost and area application must perform strict float point calculations for precise results.

Application is performing strict floating point calculation and displaying floating point values preciously.

Wage Calculation / Final output

Application must calculate wages and display output by following guidelines as specified in the assignment.

Application is displaying all outputs, and outputs pass all criteria as specified in assignment.

4.3 Evaluate independent feedback on a developed Java Program solution and make recommendations for improvements.
 

Solution:
At evaluation time this application was working fine but all error messages of the application were displaying on the console. So I got a recommendation for displaying messages in a dialog box.
 Now we have applied this recommendation by using JOptionPane to display message dialogs.


4.4 Create user documentation for developed java program solution.


Solution:
This application helps to calculate total wage of wood flooring. It can be used to calculate room area, flooring cost and extra charges for credit or debit card payment.
User can use the application by following these steps:

  • Start the application
  • Specify number of rooms on which customer want to apply wood flooring.
  • Enter details about “Length” and “Breadth” of each room.
  • Now press enter on “Breadth” field.
  • Application will automatically display “Area of Room”, “Estimated Time” and “Total Cost” for each room.
  • Click on “Next Room” button.
  • Now repeat from step-3 until details of all rooms are entered.
  • After specifying details about all the rooms, click on “View Total Amount” Button.
  • On Next screen application displays total rooms on which flooring is applied, Total estimated time for work, total cost and options for payment with debit or credit card.

4.5 Create technical documentation for support and maintenance of a java program solution.
 

Solution:
The functionality of the application given in the assignment is defined in class “WageCalculator”. This class keeps details about the work which has to be done (Flooring on rooms) like room’s length and breadth, work cost, time etc. and provides methods to calculate final amount of the work.
It provides following methods:

  • calArea(): It is used to calculate area of a room.
  • calTime(): It is used to calculate total time required for wood flooring on given area.
  • calAssistantsWage(): It is used to calculate total wage for Robert’s assistant for specific time at given rate.
  • calRobertsWage(): Since Robert also charges for his service this function is used to calculate Robert’s wage for specific time.
  • calPriceOfWood(): It is used to calculate total price of the wood for work.
  • calTotalCost(): It is used to calculate total cost of the work which has done.

Java API documentation for Wage Calculator.

Java API Documentation for wage calculator

References:

  • Java The Complete Reference (English) 8th Edition by Herb Schildt
  • Java Black Book by Steven Holzner
  • Flow Charts [Online] [Accessed on 23 November 2014]. Available on world wide web: <http://en.wikipedia.org/wiki/Flowchart>
  • UML [Online]. [Accessed on 24 November 2014]. Available on world wide web <http://www.tutorialspoint.com/uml/>
FAQ's