Skip to content

nas221/JAVALABS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

VAT Calculator Application

A Java Swing-based graphical user interface application for calculating Value Added Tax (VAT) charges on services.

Overview

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)

Features

  • 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

Project Structure

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

Classes

VATRate

Enumeration representing different VAT rates:

  • ZERO (0%)
  • LOW (5%)
  • STANDARD (20%)

Service

Represents a service with:

  • Code: Must follow format AAAA99999 (4 uppercase letters + 5 digits)
  • Name: Service description
  • Rate: VAT rate applicable to the service

Charge

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

VATCalculatorGUI

Main Swing GUI application that provides:

  • Service selection dropdown
  • Charge amount input field
  • Calculate and Clear buttons
  • Results display showing VAT amount and total

Requirements

  • Java JDK 8 or higher
  • Java Swing (included in JDK)

How to Compile

From the javaLabs directory:

javac Lab6/*.java

Or from within the Lab6 directory:

javac *.java

How to Run

From the javaLabs directory:

java Lab6.VATCalculatorGUI

Or from within the Lab6 directory:

java VATCalculatorGUI

Usage

  1. Select a Service: Choose a service from the dropdown menu

    • The current VAT rate for the selected service will be displayed
  2. Enter Charge Amount: Type a positive number in the charge amount field

  3. Calculate: Click the "Calculate VAT" button

    • VAT amount will be calculated and displayed
    • Total amount (charge + VAT) will be shown
  4. Clear: Click "Clear" to reset all fields and start over

Example Services

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 Calculation Formula

VAT Amount = Charge Amount × (VAT Rate / 100)
Total Amount = Charge Amount + VAT Amount

Error Handling

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

Code Quality

  • Comprehensive JavaDoc comments
  • Input validation
  • Error handling with user-friendly messages
  • Clean, maintainable code structure
  • Modern Swing GUI design

Author

Lab6

License

This project is for educational purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages