ITC538 Programming in Java 1: Assessment 1 - Basic Algorithms in Java

Verified

Added on  2025/04/30

|6
|477
|108
AI Summary
Desklib provides past papers and solved assignments for students. This document contains solutions for a Java programming assessment.
Document Page
ITC538 - PROGRAMMING IN JAVA 1 -
ASSESSMENT 1: BASIC ALGORITHMS
IN JAVA
1 | P a g e
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
Table of Contents
Task-1: Personal Income Tax.java..................................................................................................2
Task-2: Zoo Authorities...................................................................................................................4
2 | P a g e
Document Page
Task-1: Personal Income Tax.java
Our class name is PersonalIncomeTax, this class has a total of five function, out which four are
user defined and one is main function. In the first function by using conditional statements if the
amount is less than or equal to 8350 then the tax amount will be equal to one-tenth of the
amount, if the condition is (amount > 8350 && amount <= 33950) then the tax amount will be
taxAmount = 8350 * 10.0 / 100
taxAmount = taxAmount + (amount - 8350) * 15.0 / 100
if the condition is amount > 33950 && amount <= 82250, then tax amount will be quall to
taxAmount = 8350 * 10 / 100
taxAmount = taxAmount + (33950 - 8350) * 15 / 100
taxAmount = taxAmount + (amount - 33950) * 25 / 100
and so on the rest of the conditional statements are as follows.
In the main function, we have created an object of scanner class sc, to take input values of filing
status and taxable income. To differentiate between cases of filling status switch statements are
used. There are 5 cases and one them is default which will throw an AssertionError () method
Figure 1: Asking for filing status
Figure 2: When filling status value if 1
3 | P a g e
Document Page
Figure 3When filling status value is 0
Figure 4: When filling status value is 3
4 | P a g e
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
Task-2: Zoo Authorities
Our class name ZooAuthorities.java, this program is designed in a way to find the ticket charges
for each age group which is a child: 6-15, adult: 16-59 and senior: >59. In this program we have
two functions, one is to calculate charges and second is the main function. The calculatecharges
function has 3 parameters which are, child6To15, adults16To59, and seniorabove59.
The first screenshot shows the use of scanner class
object to get the values of the group, which is either
0 or 1. Then we have to enter the number of children
in the group, always an integer value. Then enter the
number of adults in the group, also an integer value.
Then we have to enter a number of seniors in the
group, an integer value. Then using all while loop
and conditional statements we can find the total
entry charge, which is $34 in this screenshot case.
Figure 6: Case where the number of seniors is 0
5 | P a g e
Figure 5: number of People in a group age wise
Document Page
Figure 7: Case where the number of seniors is only 1
6 | P a g e
chevron_up_icon
1 out of 6
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]