0% found this document useful (0 votes)
6 views3 pages

Java Basics Lab 01

The document outlines two programming tasks for a Java lab focused on basic concepts. The first task involves creating an Advance Personal Income Tax (APIT) calculator that computes tax based on progressive slabs for a given income, while the second task requires writing a program to reverse a user-inputted string. Both tasks include specific requirements for user input and output formatting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Java Basics Lab 01

The document outlines two programming tasks for a Java lab focused on basic concepts. The first task involves creating an Advance Personal Income Tax (APIT) calculator that computes tax based on progressive slabs for a given income, while the second task requires writing a program to reverse a user-inputted string. Both tasks include specific requirements for user input and output formatting.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CO225-Apr2025 : Software Construction

Lab 01 : Java Basics

Question 01​
Advance Personal Income Tax (APIT) Calculator

In Sri Lanka, employed individuals are subject to Advance Personal Income Tax (APIT)
on their monthly income. The tax is calculated using a progressive tax slab system
where different portions of income are taxed at different rates.

For example, for someone who earns 200,000 LKR, they will be taxed for each tax
slab(100-141,141-183,183-200) separately and the sum will be the total tax amount.

If you are unsure, you can use this tool to see how to calculate the tax amount. The goal
is to write a program that functions in a similar way.
Write a Java program named APitCalculator that calculates the Advance Personal
Income Tax for a given monthly income. The program should:

1.​ Prompt the user to enter their total monthly employment income (salary plus
allowances)
2.​ Calculate the tax payable for each tax slab
3.​ Calculate the total tax payable
4.​ Calculate the effective tax rate (total tax / monthly income) as a percentage
5.​ Calculate the salary after tax
6.​ Display the results

Output Format is supposed to be like below.


​ Calculate Your Advance Personal Income Tax (APIT)
​ Enter your total monthly employment income (salary + allowances): Rs. 300000

​ TAX SLAB RATE (%) TAX
​ Rs. 0.00 - Rs. 100000.00 0% Rs. 0.00
​ Rs. 100000.00 - Rs. 141667.00 6% Rs. 2500.00
​ Rs. 141667.00 - Rs. 183333.00 12% Rs. 5000.00
​ Rs. 183333.00 - Rs. 225000.00 18% Rs. 7500.00
​ Rs. 225000.00 - Rs. 266667.00 24% Rs. 10000.00
​ Rs. 266667.00 - Rs. 300000.00 30% Rs. 9999.90

​ Total tax payable Rs. 34999.90
​ Effective tax rate (11.67%)
​ Salary after tax Rs. 265000.10
Question 02​
ReverseString (String & char)

Write a program called ReverseString, which prompts user for a String, and prints the
reverse of the String by extracting and processing each character. The output shall look
like

Enter a String: abcdef

The reverse of the String "abcdef" is "fedcba".

Hints

For a String called inStr, you can use inStr.length() to get the length of the String; and
inStr.charAt(idx) to retrieve the char at the idx position, where idx begins at 0, up to
instr.length() - 1.

// Define variables​
String inStr; // input String​
int inStrLen; // length of the input String​
......​

// Prompt and read input as "String"​
System.out.print("Enter a String: ");​
inStr = in.next(); // use next() to read a String​
inStrLen = inStr.length();​

// Use inStr.charAt(index) in a loop to extract each character​
// The String's index begins at 0 from the left.​
// Process the String from the right​
for (int charIdx = inStrLen - 1; charIdx >= 0; --charIdx) { ​
// charIdx = inStrLen-1, inStrLen-2, ... ,0​
......​
}

You might also like