Simple Applications Using Java: 10 Beginner Projects with End-to-End Explanation
This page contains 10 simple Java applications for beginners. These projects help you practice Java basics, OOPS, collections, File Handling, exception handling, and console-based application development.
1. Simple Calculator Application in Java
This calculator application performs basic arithmetic operations like addition, subtraction, multiplication, and division. It is a good beginner project for learning methods, switch statements, and user input.
Features
- Add two numbers
- Subtract two numbers
- Multiply two numbers
- Divide two numbers
Complete Code
import java.util.Scanner;
public class CalculatorApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Simple Calculator");
System.out.print("Enter first number: ");
double a = sc.nextDouble();
System.out.print("Enter second number: ");
double b = sc.nextDouble();
System.out.println("Choose operation: +, -, *, /");
char op = sc.next().charAt(0);
switch (op) {
case '+':
System.out.println("Result: " + (a + b));
break;
case '-':
System.out.println("Result: " + (a - b));
break;
case '*':
System.out.println("Result: " + (a * b));
break;
case '/':
if (b != 0) {
System.out.println("Result: " + (a / b));
} else {
System.out.println("Cannot divide by zero");
}
break;
default:
System.out.println("Invalid operation");
}
sc.close();
}
}
Explanation
The program takes two numbers and one operator from the user. The switch
statement checks the selected operator and performs the matching operation.
2. Student Management Application in Java
This application stores student details and displays them. It is useful for practicing classes, objects, arrays, and loops.
Features
- Add student details
- Store multiple students
- Display student records
Complete Code
import java.util.Scanner;
class Student {
int id;
String name;
int marks;
void display() {
System.out.println("ID: " + id + ", Name: " + name + ", Marks: " + marks);
}
}
public class StudentManagementApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of students: ");
int n = sc.nextInt();
Student[] students = new Student[n];
for (int i = 0; i < n; i++) {
students[i] = new Student();
System.out.println("Enter details for student " + (i + 1));
System.out.print("ID: ");
students[i].id = sc.nextInt();
sc.nextLine();
System.out.print("Name: ");
students[i].name = sc.nextLine();
System.out.print("Marks: ");
students[i].marks = sc.nextInt();
}
System.out.println("\\nStudent Records:");
for (Student s : students) {
s.display();
}
sc.close();
}
}
Explanation
The Student class stores student properties. An array of Student objects
is used to store multiple student records.
3. Simple Banking Application in Java
This banking application supports deposit, withdrawal, and balance checking. It is useful for learning encapsulation and menu-driven programs.
Features
- Deposit money
- Withdraw money
- Check balance
Complete Code
import java.util.Scanner;
class BankAccount {
private double balance = 0;
void deposit(double amount) {
if (amount > 0) {
balance += amount;
System.out.println("Amount deposited successfully");
} else {
System.out.println("Invalid amount");
}
}
void withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
System.out.println("Amount withdrawn successfully");
} else {
System.out.println("Insufficient balance or invalid amount");
}
}
void checkBalance() {
System.out.println("Current Balance: " + balance);
}
}
public class BankingApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
BankAccount account = new BankAccount();
while (true) {
System.out.println("\\n1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Check Balance");
System.out.println("4. Exit");
System.out.print("Choose option: ");
int choice = sc.nextInt();
switch (choice) {
case 1:
System.out.print("Enter amount: ");
account.deposit(sc.nextDouble());
break;
case 2:
System.out.print("Enter amount: ");
account.withdraw(sc.nextDouble());
break;
case 3:
account.checkBalance();
break;
case 4:
System.out.println("Thank you");
sc.close();
return;
default:
System.out.println("Invalid choice");
}
}
}
}
Explanation
The balance is private, so it cannot be accessed directly from outside the class. This is an example of encapsulation.
4. To-Do List Application in Java
This application allows users to add, view, and remove tasks.
It is useful for practicing ArrayList.
Complete Code
import java.util.ArrayList;
import java.util.Scanner;
public class TodoApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<String> tasks = new ArrayList<>();
while (true) {
System.out.println("\\n1. Add Task");
System.out.println("2. View Tasks");
System.out.println("3. Remove Task");
System.out.println("4. Exit");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
System.out.print("Enter task: ");
tasks.add(sc.nextLine());
break;
case 2:
for (int i = 0; i < tasks.size(); i++) {
System.out.println((i + 1) + ". " + tasks.get(i));
}
break;
case 3:
System.out.print("Enter task number to remove: ");
int index = sc.nextInt() - 1;
if (index >= 0 && index < tasks.size()) {
tasks.remove(index);
System.out.println("Task removed");
} else {
System.out.println("Invalid task number");
}
break;
case 4:
sc.close();
return;
default:
System.out.println("Invalid choice");
}
}
}
}
5. ATM Simulation Application in Java
This ATM simulation project checks PIN authentication and allows withdrawal, deposit, and balance checking.
Complete Code
import java.util.Scanner;
public class ATMApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int pin = 1234;
double balance = 5000;
System.out.print("Enter PIN: ");
int enteredPin = sc.nextInt();
if (enteredPin != pin) {
System.out.println("Invalid PIN");
return;
}
while (true) {
System.out.println("\\n1. Balance");
System.out.println("2. Deposit");
System.out.println("3. Withdraw");
System.out.println("4. Exit");
int choice = sc.nextInt();
switch (choice) {
case 1:
System.out.println("Balance: " + balance);
break;
case 2:
System.out.print("Enter deposit amount: ");
balance += sc.nextDouble();
break;
case 3:
System.out.print("Enter withdraw amount: ");
double amount = sc.nextDouble();
if (amount <= balance) {
balance -= amount;
System.out.println("Withdraw successful");
} else {
System.out.println("Insufficient balance");
}
break;
case 4:
sc.close();
return;
default:
System.out.println("Invalid option");
}
}
}
}
6. Library Management Application in Java
This simple library application allows users to add and view books. It is useful for learning classes and collections.
Complete Code
import java.util.ArrayList;
import java.util.Scanner;
class Book {
String title;
String author;
Book(String title, String author) {
this.title = title;
this.author = author;
}
void display() {
System.out.println("Book: " + title + ", Author: " + author);
}
}
public class LibraryApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Book> books = new ArrayList<>();
while (true) {
System.out.println("\\n1. Add Book");
System.out.println("2. View Books");
System.out.println("3. Exit");
int choice = sc.nextInt();
sc.nextLine();
if (choice == 1) {
System.out.print("Enter book title: ");
String title = sc.nextLine();
System.out.print("Enter author name: ");
String author = sc.nextLine();
books.add(new Book(title, author));
} else if (choice == 2) {
for (Book b : books) {
b.display();
}
} else if (choice == 3) {
sc.close();
return;
} else {
System.out.println("Invalid choice");
}
}
}
}
7. Quiz Application in Java
This quiz application asks multiple-choice questions and calculates the final score.
Complete Code
import java.util.Scanner;
public class QuizApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int score = 0;
System.out.println("Q1. Which keyword is used to inherit a class?");
System.out.println("1. implements");
System.out.println("2. extends");
System.out.println("3. inherit");
int ans1 = sc.nextInt();
if (ans1 == 2) {
score++;
}
System.out.println("Q2. Which method is entry point of Java program?");
System.out.println("1. start()");
System.out.println("2. run()");
System.out.println("3. main()");
int ans2 = sc.nextInt();
if (ans2 == 3) {
score++;
}
System.out.println("Your Score: " + score + "/2");
sc.close();
}
}
8. Employee Payroll Application in Java
This project calculates employee salary using basic salary, bonus, and deductions.
Complete Code
import java.util.Scanner;
class Employee {
String name;
double basicSalary;
double bonus;
double deduction;
double calculateNetSalary() {
return basicSalary + bonus - deduction;
}
}
public class PayrollApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Employee emp = new Employee();
System.out.print("Enter employee name: ");
emp.name = sc.nextLine();
System.out.print("Enter basic salary: ");
emp.basicSalary = sc.nextDouble();
System.out.print("Enter bonus: ");
emp.bonus = sc.nextDouble();
System.out.print("Enter deduction: ");
emp.deduction = sc.nextDouble();
System.out.println("Employee: " + emp.name);
System.out.println("Net Salary: " + emp.calculateNetSalary());
sc.close();
}
}
9. Contact Book Application in Java
This application stores contact names and phone numbers using HashMap.
Complete Code
import java.util.HashMap;
import java.util.Scanner;
public class ContactBookApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
HashMap<String, String> contacts = new HashMap<>();
while (true) {
System.out.println("\\n1. Add Contact");
System.out.println("2. Search Contact");
System.out.println("3. View Contacts");
System.out.println("4. Exit");
int choice = sc.nextInt();
sc.nextLine();
switch (choice) {
case 1:
System.out.print("Enter name: ");
String name = sc.nextLine();
System.out.print("Enter phone: ");
String phone = sc.nextLine();
contacts.put(name, phone);
break;
case 2:
System.out.print("Enter name to search: ");
String searchName = sc.nextLine();
System.out.println("Phone: " + contacts.get(searchName));
break;
case 3:
System.out.println(contacts);
break;
case 4:
sc.close();
return;
default:
System.out.println("Invalid choice");
}
}
}
}
10. Expense Tracker Application in Java
This project stores expenses and calculates total spending. It is useful for practicing collections and loops.
Complete Code
import java.util.ArrayList;
import java.util.Scanner;
public class ExpenseTrackerApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList<Double> expenses = new ArrayList<>();
while (true) {
System.out.println("\\n1. Add Expense");
System.out.println("2. View Total Expense");
System.out.println("3. Exit");
int choice = sc.nextInt();
if (choice == 1) {
System.out.print("Enter expense amount: ");
expenses.add(sc.nextDouble());
} else if (choice == 2) {
double total = 0;
for (double expense : expenses) {
total += expense;
}
System.out.println("Total Expense: " + total);
} else if (choice == 3) {
sc.close();
return;
} else {
System.out.println("Invalid choice");
}
}
}
}
Summary
These 10 simple Java applications are excellent for beginners. They cover important Java concepts such as classes, objects, loops, arrays, collections, encapsulation, user input, and menu-driven programming. Practicing these projects will help you build confidence for interviews and real-world Java development.
Simple Java Applications FAQ
Which Java project is best for beginners?
Calculator, Student Management, Banking, To-Do List, and ATM applications are best for beginners.
Can I add database support to these Java projects?
Yes. After learning JDBC or Spring Boot, you can connect these projects to MySQL or PostgreSQL.
Are these projects useful for interviews?
Yes. These projects demonstrate practical understanding of Java basics, OOPS, collections, and logic building.