ST.
MARY‟S CONVENT SCHOOL
Begur-Koppa Road, Bangalore-83
Computer Science Project
[Year 2025-26]
Guided by: Mrs. Libi Chacko Submitted by: Harshith Kumar .G
Class: IX „B‟
Certificate
This is to certify that Harshith Kumar G , a student
of class IX has successfully completed “Computer”
project under the guidance of Mrs. Libi Chacko. This
project is the individual work of the student. I certify
that this project is up to my expectation and as per
the guidelines issued by CISCE.
Signature of External Examiner Signature of Internal Examiner
Principal‟s Seal & signature
Acknowledgement
I take this opportunity to express my
profound gratitude and deep regards to my guide
Mrs. Libi Chacko for her exemplary guidance,
monitoring and encouragement to complete this
project.
I would also like to extend my gratitude to
[Link] C.J. the principal of St. Mary's
Convent School, for her cordial support and
cooperation which helped me in completing this
task. I thank my parents for their cooperation and
friends who have helped in various ways.
Name of the Student : Harshith Kumar.G
Date:
Index
Sl. Pg.
No. Title No.
01. Write a program to input two numbers and check whether they 1-2
are twin prime number or not
02. Write a program to input a number and find the sum of all even 3-4
and odd digits present in that number.
03. Write a program to input a number and find its factorial 5-6
04. Write a program to input a number and find the sum of its 7-8
first ten multiples.
05. Write a program to input the side length of a [Link] a 9-10
menu,based upon the following options [Link] find the area 2. To
find perimeter [Link] find diagonal
06. Write a program to input a year and check whether it is a leap 11-12
year,century leap year or a century leap year but not a leap year.
07. Write a program to input three numbers and check whether they 13-14
are equal or [Link] they are unequal numbers,then display the
greatest among them ,otherwise ,display the message “All
numbers are equal”.
08. Write a program to check whether a number is Abundant 15-16
number or not.
09. Write a program to print given pattern. 17-18
A
BC
DEF
GHI
KLMNO
10. Write a program to two numbers x and y, input another 19-20
number z and print all the numbers between x and y, which are
divisible by z
11. Write a program to check whether the number entered by the 21-22
user is palindrome or not.
12. Write a program to count how many times a number can be 23-24
divided by 2
13. Write a program to check whether the number entered by the 25-26
user is a perfect number or not.
14. Write a program to input two numbers and find the value of 27-28
one number raised to the power of another.
15. Write a program to display the table of a number entered by 29-30
the user.
16. Write a menu driven program that calculates the area of the 31-33
various geometrical figures on the basis of the choice given by
user.
17. Write a program to input the units of electricity consumed and 34-35
find the bill charged at the following rates.
Units Charges
First 100 units ₹2 per unit
Next 100 units ₹3 per unit
Next 200 units ₹4 per unit
Above 400 units ₹5 per unit
18. Write a program to input the month number and print the name 36-37
of the month accordingly.
19. Write a program to print the Fibonacci series of „n‟ terms 38-39
where „n‟ is input by user.
0 1 1 2 3 5 8 13 21
20. WAP to generate the following patterns using iteration 40-41
statements.
* 54321
*# 5432
*#* 543
*#*# 54
*#*#* 5
[Link] a program to input two numbers and check whether they are twin
prime number or not
import [Link];
public class TwinPrimeChecker {
// Method to check if a number is prime
public static boolean isPrime(int num) {
if (num < 2) {
return false;
}
for (int i = 2; i <= [Link](num); i++) {
if (num % i == 0) {
return false;
}
}
return true;
}
// Method to check if two numbers are twin primes
public static boolean areTwinPrimes(int num1, int num2) {
return (isPrime(num1) && isPrime(num2) && [Link](num1 - num2) == 2);
}
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
// Input two numbers
[Link]("Enter first number: ");
int num1 = [Link]();
[Link]("Enter second number: ");
int num2 = [Link]();
// Check if they are twin primes
if (areTwinPrimes(num1, num2)) {
[Link](num1 + " and " + num2 + " are Twin Prime Numbers.");
} else {
[Link](num1 + " and " + num2 + " are NOT Twin Prime Numbers.");
}
[Link]();
}
}
Output:
[Link] a program to input a number and find the sum of all even and odd digits
present in that number.
import [Link];
public class SumEvenOddDigits {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
// Input the number
[Link]("Enter a number: ");
int num = [Link]();
int evenSum = 0, oddSum = 0;
// Extracting digits and calculating sum
while (num > 0) {
int digit = num % 10; // Get last digit
if (digit % 2 == 0) {
evenSum += digit; // Add to even sum
} else {
oddSum += digit; // Add to odd sum
}
num /= 10; // Remove last digit
}
// Display results
[Link]("Sum of even digits: " + evenSum);
[Link]("Sum of odd digits: " + oddSum);
[Link]();
}
}
Output:
3. Write a program to input a number and find its factorial
import [Link];
public class Factorial {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
// Input number
[Link]("Enter a number: ");
int num = [Link]();
long factorial = 1; // Variable to store factorial result
// Calculate factorial
for (int i = 1; i <= num; i++) {
factorial *= i;
}
// Display result
[Link]("Factorial of " + num + " is: " + factorial);
[Link]();
}
}
Output:
4. Write a program to input a number and find the sum of its first ten
multiples.
import [Link];
public class SumOfMultiples {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number
[Link]("Enter a number: ");
int num = [Link]();
int sum = 0;
// Calculate the sum of the first ten multiples
for (int i = 1; i <= 10; i++) {
sum += num * i;
}
// Output the result
[Link]("The sum of the first ten multiples of " + num + " is: " +
sum);
[Link]();
}
}
Output:
[Link] a program to input the side length of a [Link] a
menu,based upon the following options [Link] find the area 2. To find
perimeter [Link] find diagonal
import [Link];
public class SquareOperations {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the side of the square
[Link]("Enter the side length of the square: ");
double side = [Link]();
// Display the menu
[Link]("\nMenu:");
[Link]("1. Find the Area");
[Link]("2. Find the Perimeter");
[Link]("3. Find the Diagonal");
[Link]("Enter your choice (1/2/3): ");
int choice = [Link]();
// Process the choice
switch (choice) {
case 1:
double area = side * side;
[Link]("The area of the square is: " + area);
break;
case 2:
double perimeter = 4 * side;
[Link]("The perimeter of the square is: " + perimeter);
break;
case 3:
double diagonal = side * [Link](2);
[Link]("The diagonal of the square is: " + diagonal);
break;
default:
[Link]("Invalid choice! Please select a valid option.");
}
[Link]();
}
}
Output::
[Link] a program to input a year and check whether it is a leap
year,century leap year or a century leap year but not a leap year.
import [Link];
public class LeapYearChecker {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the year
[Link]("Enter a year: ");
int year = [Link]();
// Check the conditions
if (year % 400 == 0) {
[Link](year + " is a Century Leap Year.");
} else if (year % 100 == 0) {
[Link](year + " is a Century Year but NOT a Leap Year.");
} else if (year % 4 == 0) {
[Link](year + " is a Leap Year.");
} else {
[Link](year + " is NOT a Leap Year.");
}
[Link]();
}
}
Output:
[Link] a program to input three numbers and check whether they are
equal or [Link] they are unequal numbers,then display the greatest among
them ,otherwise ,display the message “All numbers are equal”.
import [Link];
public class CompareThreeNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input three numbers
[Link]("Enter the first number: ");
int num1 = [Link]();
[Link]("Enter the second number: ");
int num2 = [Link]();
[Link]("Enter the third number: ");
int num3 = [Link]();
// Check if all numbers are equal
if (num1 == num2 && num2 == num3) {
[Link]("All numbers are equal.");
} else {
// Find the greatest number
int greatest = num1;
if (num2 > greatest) {
greatest = num2;
}
if (num3 > greatest) {
greatest = num3;
}
[Link]("The greatest number is: " + greatest);
}
[Link]();
}
}
Output:
[Link] a program to check whether a number is Abundant number or
not.
import [Link];
public class AbundantNumber {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number
[Link]("Enter a number: ");
int num = [Link]();
int sum = 0;
// Find the sum of proper divisors
for (int i = 1; i <= num / 2; i++) {
if (num % i == 0) {
sum += i;
}
}
// Check if the number is Abundant
if (sum > num) {
[Link](num + " is an Abundant Number.");
} else {
[Link](num + " is NOT an Abundant Number.");
}
[Link]();
}
}
Output:
[Link] a program to print given pattern.
A
BC
DEF
GHI
KLMNO
public class AlphabetPattern {
public static void main(String[] args) {
char letter = 'A'; // Start with 'A'
int rows = 5; // Number of rows in the pattern
for (int i = 1; i <= rows; i++) { // Outer loop for rows
for (int j = 1; j <= i; j++) { // Inner loop for printing letters
[Link](letter);
letter++; // Move to next letter
}
[Link](); // Move to the next line
}
}
}
Output:
[Link] a program to two numbers x and y, input another number z and
print all the numbers between x and y, which are divisible by z
import [Link];
public class DivisibleNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input x, y, and z
[Link]("Enter the starting number (x): ");
int x = [Link]();
[Link]("Enter the ending number (y): ");
int y = [Link]();
[Link]("Enter the divisor (z): ");
int z = [Link]();
// Validate inputs
if (x > y) {
[Link]("Invalid input! x should be less than or equal to y.");
} else {
[Link]("Numbers between " + x + " and " + y + " divisible by " +
z + ":");
boolean found = false;
// Loop through numbers from x to y
for (int i = x; i <= y; i++) {
if (i % z == 0) {
[Link](i + " ");
found = true;
}
}
// If no numbers were found
if (!found) {
[Link]("None");
}
}
[Link]();
}
}
Output:
[Link] a program to check whether the number entered by the user is
palindrome or not.
import [Link];
public class PalindromeNumber {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number
[Link]("Enter a number: ");
int num = [Link]();
int originalNum = num; // Store original number for comparison
int reversedNum = 0;
// Reverse the number
while (num > 0) {
int digit = num % 10; // Get last digit
reversedNum = reversedNum * 10 + digit; // Append digit to
reversed number
num /= 10; // Remove last digit
}
// Check if the original number is equal to the reversed number
if (originalNum == reversedNum) {
[Link](originalNum + " is a Palindrome Number.");
} else {
[Link](originalNum + " is NOT a Palindrome
Number.");
}
[Link]();
}
}
Output:
12. Write a program to count how many times a number can be divided by
2.
import [Link];
public class CountDivisionsByTwo {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number
[Link]("Enter a number: ");
int num = [Link]();
int count = 0; // Counter to track divisions
// Divide the number by 2 repeatedly until it becomes less than 1
while (num >= 1) {
num /= 2;
count++;
}
// Output the result
[Link]("The number can be divided by 2, " + count + " times
before it becomes less than 1.");
[Link]();
}
}
Output:
13. Write a program to check whether the number entered by the user is a
perfect number or not.
import [Link];
public class PerfectNumber {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number
[Link]("Enter a number: ");
int num = [Link]();
int sum = 0; // To store the sum of divisors
// Find the sum of proper divisors
for (int i = 1; i <= num / 2; i++) {
if (num % i == 0) {
sum += i;
}
}
// Check if the sum of divisors equals the number
if (sum == num) {
[Link](num + " is a Perfect Number.");
} else {
[Link](num + " is NOT a Perfect Number.");
}
[Link]();
}
}
Output:
14. Write a program to input two numbers and find the value of one
number raised to the power of another.
import [Link];
public class PowerCalculation {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input base and exponent
[Link]("Enter the base number: ");
double base = [Link]();
[Link]("Enter the exponent: ");
double exponent = [Link]();
// Calculate power using [Link]()
double result = [Link](base, exponent);
// Display result
[Link](base + " raised to the power of " + exponent + " is: " +
result);
[Link]();
}
}
Output:
15. Write a program to display the table of a number entered by
the user
import [Link];
public class MultiplicationTable {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number
[Link]("Enter a number: ");
int num = [Link]();
// Print the multiplication table
[Link]("Multiplication Table of " + num + ":");
for (int i = 1; i <= 10; i++) {
[Link](num + " × " + i + " = " + (num * i));
}
[Link]();
}
}.
Output:
16. Write a menu driven program that calculates the area of the various
geometrical figures on the basis of the choice given by user.
import [Link];
public class AreaCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
while (true) {
// Display the menu
[Link]("\nChoose a geometrical figure:");
[Link]("1. Circle");
[Link]("2. Rectangle");
[Link]("3. Triangle");
[Link]("4. Square");
[Link]("5. Exit");
[Link]("Enter your choice: ");
int choice = [Link]();
switch (choice) {
case 1: // Circle
[Link]("Enter the radius of the circle: ");
double radius = [Link]();
double circleArea = [Link] * radius * radius;
[Link]("Area of Circle: " + circleArea);
break;
case 2: // Rectangle
[Link]("Enter the length of the rectangle: ");
double length = [Link]();
[Link]("Enter the width of the rectangle: ");
double width = [Link]();
double rectangleArea = length * width;
[Link]("Area of Rectangle: " + rectangleArea);
break;
case 3: // Triangle
[Link]("Enter the base of the triangle: ");
double base = [Link]();
[Link]("Enter the height of the triangle: ");
double height = [Link]();
double triangleArea = 0.5 * base * height;
[Link]("Area of Triangle: " + triangleArea);
break;
case 4: // Square
[Link]("Enter the side length of the square: ");
double side = [Link]();
double squareArea = side * side;
[Link]("Area of Square: " + squareArea);
break;
case 5: // Exit
[Link]("Exiting the program...");
[Link]();
return;
default:
[Link]("Invalid choice! Please enter a number between
1 and 5.");
}
}
}
}
Output:
17. Write a program to input the units of electricity consumed and find
the bill charged at the following rates.
Units Charges
First 100 units ₹2 per unit
Next 100 units ₹3 per unit
Next 200 units ₹4 per unit
Above 400 units ₹5 per unit
import [Link];
public class ElectricityBill {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number of units consumed
[Link]("Enter the number of electricity units consumed:
");
int units = [Link]();
double billAmount = 0;
// Calculate the bill based on units consumed
if (units <= 100) {
billAmount = units * 2;
} else if (units <= 200) {
billAmount = (100 * 2) + ((units - 100) * 3);
} else if (units <= 400) {
billAmount = (100 * 2) + (100 * 3) + ((units - 200) * 4);
} else {
billAmount = (100 * 2) + (100 * 3) + (200 * 4) + ((units - 400) *
5);
}
// Display the total bill amount
[Link]("Total electricity bill: ₹" + billAmount);
[Link]();
}
}
Output:
18. Write a program to input the month number and print the name of the
month accordingly.
import [Link];
public class MonthName {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the month number
[Link]("Enter the month number (1-12): ");
int monthNumber = [Link]();
// Determine the month name using switch-case
String monthName;
switch (monthNumber) {
case 1: monthName = "January"; break;
case 2: monthName = "February"; break;
case 3: monthName = "March"; break;
case 4: monthName = "April"; break;
case 5: monthName = "May"; break;
case 6: monthName = "June"; break;
case 7: monthName = "July"; break;
case 8: monthName = "August"; break;
case 9: monthName = "September"; break;
case 10: monthName = "October"; break;
case 11: monthName = "November"; break;
case 12: monthName = "December"; break;
default: monthName = "Invalid month number! Please enter a number
between 1 and 12.";
}
// Print the result
[Link](monthName);
[Link]();
}
}
Output:
19. Write a program to print the Fibonacci series of „n‟ terms where „n‟
is input by user. 0 1 1 2 3 5 8 13 21
import [Link];
public class FibonacciSeries {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number of terms
[Link]("Enter the number of terms in Fibonacci series:
");
int n = [Link]();
int first = 0, second = 1; // First two terms
[Link]("Fibonacci Series up to " + n + " terms:");
// Print Fibonacci series using loop
for (int i = 1; i <= n; i++) {
[Link](first + " ");
int next = first + second; // Compute next term
first = second; // Update first
second = next; // Update second
}
[Link]();
}
}
Output:
20. WAP to generate the following patterns using iteration statements.
* 54321
*# 5432
*#* 543
*#*# 54
*#*#* 5
import [Link];
public class PatternGenerator {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Input the number of rows
[Link]("Enter the number of rows: ");
int rows = [Link]();
[Link]("\nPattern 1:");
// Generating the first pattern
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
// Print '*' for odd positions, '#' for even positions
if (j % 2 == 0) {
[Link]("# ");
} else {
[Link]("* ");
}
}
[Link]();
}
[Link]("\nPattern 2:");
// Generating the second pattern
for (int i = rows; i >= 1; i--) {
for (int j = rows; j >= rows - i + 1; j--) {
[Link](j + " ");
}
[Link]();
}
[Link]();
}
}
Output:
Bibliography
Book: Logix Computer Applications
Publisher: KIPS
Internet: [Link] [Link]
[Link]