1.
Write your own code and include comments for each block to explain the process and logic
used.
2. At the beginning of your program, please add your basic information as a header
including: Student ID, Full name, DoB, Created date.
3. Place your code in a folder named <studentID>_<Fullname>_w1BasicJava, zip the
folder, and upload it to the provided link.
4. If you're unable to solve any of the basic exercises, you can choose one of the advanced
ones as an alternative option.
Basic Exercises (Compulsory):
Exercise 1. Simple Calculator: Implement a simple calculator that can perform addition,
subtraction, multiplication, and division based on user input.
Exercise 2. Largest of Three Numbers:
Write a program to find the largest of three numbers entered by the user.
Exercise 3. Factorial of a Number:
Write a Java program that calculates the factorial of a given number using
loops.
Exercise 4. Fibonacci Sequence:
Create a program that prints the first n numbers of the Fibonacci sequence.
Exercise 5. Prime Number Check:
Write a Java program to check whether a given number is prime or not.
Exercise 6. Palindrome Check:
Write a program to check if a given string or number is a palindrome.
Exercise 7. Reverse a String:
Create a Java program that takes a string input from the user and prints the
reversed string.
Exercise 8. Sum of Digits:
Write a program to calculate the sum of digits of a given number.
Exercise 9. Array Sorting:
Implement a Java program that sorts an array of integers in ascending order
using any sorting algorithm (e.g., bubble sort, selection sort).
Exercise 10. Find Largest and Smallest in Array:
Write a program to find the largest and smallest elements in an array of integers.
Exercise 11. Count Vowels and Consonants in a String:
Create a Java program to count the number of vowels and consonants in a given
string.
Exercise 12. Simple Number Guessing Game:
Implement a simple number guessing game where the program generates a
random number, and the user has to guess it, with hints provided for "too high"
or "too low."
Exercise 13. Matrix Multiplication:
Write a Java program to multiply two matrices and display the result.
Exercise 14. Armstrong Number:
Create a program to check if a given number is an Armstrong number (a number
equal to the sum of its digits raised to the power of the number of digits).
Exercise 15. Merge Two Sorted Arrays:
Implement a program that merges two sorted arrays into one sorted array
without using in-built methods.
Exercise 16. GCD and LCM of Two Numbers:
Write a program to find the greatest common divisor (GCD) and least common
multiple (LCM) of two numbers using loops.
Exercise 17. Binary to Decimal and Decimal to Binary:
Implement a Java program that converts a binary number to decimal and vice
versa.
Exercise 18. Check for Anagrams:
Write a program to check if two input strings are anagrams of each other.
Exercise 19. GCD and LCM of Two Numbers:
Write a program to find the greatest common divisor (GCD) and least common
multiple (LCM) of two numbers using loops.
Exercise 20. Binary to Decimal and Decimal to Binary:
Implement a Java program that converts a binary number to decimal and vice
versa.
Advance Exercises (option):
• Implement a Stack:
Write a Java program to implement a stack (LIFO structure) using arrays and methods such
as push, pop, and peek.
• Implement a Queue:
Create a program that implements a queue (FIFO structure) using arrays or linked lists, with
methods for enqueue and dequeue.
• Check for Anagrams:
Write a program to check if two input strings are anagrams of each other.
• Caesar Cipher Encryption:
Create a Java program to encrypt and decrypt a message using the Caesar cipher algorithm,
shifting characters by a specified number of positions.
• Sum of Array Elements Using Recursion:
Implement a program that finds the sum of elements in an array using recursion.
• Find Duplicates in an Array:
Write a program to find duplicate elements in an array and count how many times they
occur.
• Binary Search Algorithm:
Implement the binary search algorithm to find an element in a sorted array, and return its
index or -1 if not found.
• Count Occurrences of a Character in a String:
Write a Java program that counts the occurrences of a specific character in a given string.
• Pascal’s Triangle:
Create a program that prints Pascal’s triangle up to n rows, where n is provided by the user.
• Sudoku Solver:
Implement a Java program that can solve a 9x9 Sudoku puzzle using a backtracking
algorithm.