A Java Swing-based graphical user interface application for calculating Value Added Tax (VAT) charges on services.
This application provides a user-friendly GUI to:
- Select a service from a predefined list
- Enter a charge amount
- Automatically calculate VAT based on the service's VAT rate
- Display VAT amount and total charge (charge + VAT)
- Service Selection: Choose from multiple services with different VAT rates
- VAT Calculation: Automatic calculation based on service VAT rate (0%, 5%, or 20%)
- Input Validation: Ensures valid service codes and positive charge amounts
- Clear Interface: Modern, intuitive GUI with clear labels and results display
- Error Handling: User-friendly error messages for invalid inputs
Lab6/
├── VATRate.java # Enum defining VAT rates (ZERO, LOW, STANDARD)
├── Service.java # Service class with code, name, and VAT rate
├── Charge.java # Charge class that calculates VAT for a service
├── VATCalculatorGUI.java # Main GUI application
└── README.md # This file
Enumeration representing different VAT rates:
ZERO(0%)LOW(5%)STANDARD(20%)
Represents a service with:
- Code: Must follow format
AAAA99999(4 uppercase letters + 5 digits) - Name: Service description
- Rate: VAT rate applicable to the service
Represents a charge for a service:
- Validates that service is not null
- Validates that charge amount is positive
- Calculates VAT amount based on service's VAT rate
Main Swing GUI application that provides:
- Service selection dropdown
- Charge amount input field
- Calculate and Clear buttons
- Results display showing VAT amount and total
- Java JDK 8 or higher
- Java Swing (included in JDK)
From the javaLabs directory:
javac Lab6/*.javaOr from within the Lab6 directory:
javac *.javaFrom the javaLabs directory:
java Lab6.VATCalculatorGUIOr from within the Lab6 directory:
java VATCalculatorGUI-
Select a Service: Choose a service from the dropdown menu
- The current VAT rate for the selected service will be displayed
-
Enter Charge Amount: Type a positive number in the charge amount field
-
Calculate: Click the "Calculate VAT" button
- VAT amount will be calculated and displayed
- Total amount (charge + VAT) will be shown
-
Clear: Click "Clear" to reset all fields and start over
The application comes with sample services:
- Book Sales (BOOK12345) - 0% VAT
- Food Service (FOOD12345) - 5% VAT
- Consulting (CONS12345) - 20% VAT
- Software License (SOFT12345) - 20% VAT
- Medical Equipment (MEDI12345) - 0% VAT
VAT Amount = Charge Amount × (VAT Rate / 100)
Total Amount = Charge Amount + VAT Amount
The application handles various error cases:
- Invalid service code format
- Null or empty service
- Non-positive charge amounts
- Invalid number format in charge field
- Missing input fields
- Comprehensive JavaDoc comments
- Input validation
- Error handling with user-friendly messages
- Clean, maintainable code structure
- Modern Swing GUI design
Lab6
This project is for educational purposes.