COIT20245 Java Programming Assignment: Income Tax Calculation

Verified

Added on  2022/09/16

|3
|594
|22
Homework Assignment
AI Summary
This document presents a Java console application designed to calculate income tax for N employees, where N is a constant derived from the student's ID. The program implements the tax calculation based on a provided income tax table with five different tax groups and corresponding tax rates. The solution utilizes Java's Scanner class for user input of employee incomes and employs conditional logic to determine the applicable tax bracket for each employee. The implementation includes the use of inheritance, flags to track employee counts within different income groups, and the Math.max() function for debugging and identifying the maximum number of employees within each tax bracket. The program takes employee income as input and calculates individual income tax, displaying the results for each employee. The provided solution includes two Java files, TaxTest.java and Tax.java, to implement the described functionality.
Document Page
Running head: COIT20245: JAVA PROGRAMING
COIT20245: Java Programing
Name of the Student
Name of the University
Authors note
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
1COIT20245: JAVA PROGRAMING
Implementation
While implementing the logic behind the program, two java files are created
according to the specification which are namely TaxTest.java and Tax.java. Tax.java contains
the main implementation for calculating depending upon the income of the employee and
different tax stages as provided in the specification through checking of the user input with
the defined stags. In addition to that, the concept of flags are used in order to track the count
of employees under different groups as specified by the program depending on their income
and tax for some specific employee. Whenever a specific condition is matched the value of
flag is increased.
The concept of Inheritance of Java is used in this project. Using this mechanism in
the program is helpful to make a class object to acquire the behaviours/properties of another
object or the parent object. This concept was very helpful in carrying out or use the defined
methods/functions that are declared and defined in the parent class.
Through the use of the inheritance, it is possible to create new classes and objects that
were built upon previously defined classes. Whenever a class inherits the behaviour of an
existing class is derived then it is possible to reuse defined methods as well as fields declared
in parent class.
Due to the restriction on the use of the Array data structure, thus in order to find out
the maximum number of employees in the different group. In order to calculate the
highest/smallest number of employees in the different groups the Math.max functions used
for debugging , execution of the program.
Document Page
2COIT20245: JAVA PROGRAMING
Input and use of the loops in the Program
In order to get the user input for the income of the employees, the Scanner is a class
utilized. This class resides in java.util package and is helpful in getting the input of the
primitive data types such as double, int and so on. For a console based program use of this
class can be the easiest technique in order to read input from user through the keyboard. Even
though this method is not considered as the efficient one in the scenarios where time is a
constraint. In order to create an object of the Scanner class, the predefined object System.in
is passed to the class. This system.in represents standard input stream for the programs. It is
also possible to pass objects of class file in case of reading the input from a file.
Use of Math Functions
In order determine the highest number of employees in different tax groups, the
Math.max() method is used. Java.lang.math.max() is one of the inbuilt function in Java that
helps in comparing two numbers among and returns biggest number of those two numbers.
The argument types that can be passed to this inbuilt method/function are double, int, long
and float. This function can even generate the result of comparison among the provided
negative and a positive argument passed to this function and this inbuilt method generate the
positive result. This method is also capable of comparing two negative parameters/arguments
that are passed to the method and returns the number with the lower magnitude as the result
of the comparison.
chevron_up_icon
1 out of 3
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]