ST.
MARY‟S CONVENT SCHOOL
Begur-Koppa Road,Bangalore-83
Computer Science Project
[Year 2025-26]
Guided by: Mrs.Libi Chacko Submitted by: Mohit Patel
Class : IX “B”
Certificate
This is to certify that Mohit Patel, 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 andas 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
Sr.Sanjana 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 andfriends
who have helped in various ways.
Name of the Student: Mohit Patel
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 of a square.Develop a 9-10
menu,based upon the following options 1.To find the area 2. To
find perimeter 3.To 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 not.if 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
1.Write a program to input two numbers and check whether they are twin
prime number or not
import java.util.Scanner;
public class TwinPrimeChecker {
// Method to check if a number is prime
public static boolean isPrime(int num) {
if (num <= 1) return false;
for (int i = 2; i <= Math.sqrt(num); i++) {
if (num % i == 0) return false;
}
return true;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input two numbers
System.out.print("Enter the first number: ");
int a = scanner.nextInt();
System.out.print("Enter the second number: ");
int b = scanner.nextInt();
// Check for twin prime
if (isPrime(a) && isPrime(b) && Math.abs(a - b) == 2) {
System.out.println(a + " and " + b + " are Twin Prime numbers.");
} else {
System.out.println(a + " and " + b + " are NOT Twin Prime numbers.");
}
scanner.close();
}
}
2. Write a program to input a number and find the sum of all even and odd digits
present in that number.
import java.util.Scanner;
public class SumEvenOddDigits {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input the number
System.out.print("Enter a number: ");
int num = sc.nextInt();
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
System.out.println("Sum of even digits: " + evenSum);
System.out.println("Sum of odd digits: " + oddSum);
sc.close();
}
}
3. Write a program to input a number and find its factorial.
import java.util.Scanner;
public class FactorialCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input the number
System.out.print("Enter a number: ");
int number = scanner.nextInt();
long factorial = 1;
// Factorial is not defined for negative numbers
if (number < 0) {
System.out.println("Factorial is not defined for negative numbers.");
} else {
for (int i = 1; i <= number; i++) {
factorial *= i;
}
System.out.println("Factorial of " + number + " is: " + factorial);
}
scanner.close();
}
}
4. Write a program to input a number and find the sum of its first ten multiples .
import java.util.Scanner;
public class SumOfMultiples {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input the number
System.out.print("Enter a number: ");
int number = scanner.nextInt();
int sum = 0;
// Loop to calculate the sum of first 10 multiples
for (int i = 1; i <= 10; i++) {
sum += number * i;
}
// Output the result
System.out.println("Sum of the first 10 multiples of " + number + " is: " + sum);
scanner.close();
}
}
5. Write a program to input the side of a square.Develop a menu,based upon
following options 1.To find the area 2. To find perimeter 3.To find diagonal.
import java.util.Scanner;
public class SquareMenu {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input the side of the square
System.out.print("Enter the side length of the
square: "); double side = sc.nextDouble();
// Display menu
System.out.println("\nMenu:");
System.out.println("1. To find the area");
System.out.println("2. To find the perimeter");
System.out.println("3. To find the diagonal");
System.out.print("Enter your choice (1-3): ");
int choice = sc.nextInt();
switch (choice) {
case 1:
double area = side * side;
System.out.println("Area of the square = " + area);
break;
case 2:
double perimeter = 4 * side;
System.out.println("Perimeter of the square = " + perimeter);
break;
case 3:
double diagonal = side * Math.sqrt(2);
System.out.println("Diagonal of the square = " + diagonal);
break;
default:
System.out.println("Invalid choice. Please enter 1, 2 or 3.");
}
sc.close();
}
}
6. Write 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 java.util.Scanner;
public class YearChecker {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input year
System.out.print("Enter a year: ");
int year = sc.nextInt();
// Check year type
if (year % 100 == 0) {
if (year % 400 == 0) {
System.out.println(year + " is a Century Leap Year.");
} else {
System.out.println(year + " is a Century Year but NOT a Leap Year.");
}
} else if (year % 4 == 0) {
System.out.println(year + " is a Leap Year.");
} else {
System.out.println(year + " is NOT a Leap Year.");
}
sc.close();
}
}
7. Write a program to input three numbers and check whether they are equal or
not.if they are unequal numbers,then display the greatest among them
,otherwise ,display the message “All numbers are equal”.
import java.util.Scanner;
public class CompareThreeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input three numbers
System.out.print("Enter the first number: ");
int num1 = sc.nextInt();
System.out.print("Enter the second number: ");
int num2 = sc.nextInt();
System.out.print("Enter the third number: ");
int num3 = sc.nextInt();
// Check if all are equal
if (num1 == num2 && num2 == num3) {
System.out.println("All numbers are equal.");
} else {
// Find the greatest
int greatest = num1;
if (num2 > greatest) {
greatest = num2;
}
if (num3 > greatest) {
greatest = num3;
}
System.out.println("The greatest number is: " + greatest);
}
sc.close();
}
}
8. Write a program to check whether a number is Abundant number or not.
import java.util.Scanner;
public class AbundantNumber {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input the number
System.out.print("Enter a number: ");
int num = sc.nextInt();
int sum = 0;
// Find sum of proper divisors
for (int i = 1; i <= num / 2; i++) {
if (num % i == 0) {
sum += i;
}
}
// Check if number is abundant
if (sum > num) {
System.out.println(num + " is an Abundant Number.");
} else {
System.out.println(num + " is NOT an Abundant Number.");
}
sc.close();
}
}
9. Write a program to print given pattern.
A
BC
DEF
GHI
KLMNO
import java.util.Scanner;
public class AlphabetPattern {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Take number of rows as input
System.out.print("Enter number of rows: ");
int rows = sc.nextInt();
char ch = 'A';
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(ch);
ch++;
}
System.out.println();
}
sc.close();
}
}
10. Write 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 java.util.Scanner;
public class DivisibleNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input for x, y, and z
System.out.print("Enter the starting number (x): ");
int x = scanner.nextInt();
System.out.print("Enter the ending number (y): ");
int y = scanner.nextInt();
System.out.print("Enter the number to check divisibility (z): ");
int z = scanner.nextInt();
System.out.println("Numbers between " + x + " and " + y + " divisible by " + z
+ ":");
// Ensure x is less than or equal to y
if (x > y) {
int temp = x;
x = y;
y = temp;
}
// Print numbers divisible by z
for (int i = x; i <= y; i++) {
if (i % z == 0) {
System.out.println(i);
}
}
scanner.close();
}
}
11. Write a program to check whether the number entered by the user is
palindrome or not.
import java.util.Scanner;
public class PalindromeCheck {
public static void main(String[] args) {
// Create Scanner object to read input
Scanner scanner = new Scanner(System.in);
// Ask user for a number
System.out.print("Enter a number: ");
int number = scanner.nextInt();
// Store original number to compare later
int originalNumber = number;
int reversedNumber = 0;
// Reverse the number
while (number != 0) {
int digit = number % 10;
reversedNumber = reversedNumber * 10 + digit;
number /= 10;
}
// Check if the original and reversed numbers are the same
if (originalNumber == reversedNumber) {
System.out.println(originalNumber + " is a palindrome.");
} else {
System.out.println(originalNumber + " is not a palindrome.");
}
scanner.close();
}
}
12. Write a program to count how many times a number can be divided by 2.
import java.util.Scanner;
public class DivideByTwoCounter {
public static void main(String[] args) {
// Create Scanner object to read input
Scanner scanner = new Scanner(System.in);
// Ask user for a number
System.out.print("Enter a number: ");
int number = scanner.nextInt();
int count = 0;
// Check how many times the number can be divided by 2
while (number % 2 == 0 && number != 0) {
number = number / 2;
count++;
}
// Print the result
System.out.println("The number can be divided by 2, " + count + " times.");
scanner.close();
}
}
13. Write a program to check whether the number entered by the user is a
perfect number or not.
import java.util.Scanner;
public class PerfectNumberCheck {
public static void main(String[] args) {
// Create Scanner object
Scanner scanner = new Scanner(System.in);
// Ask user to enter a number
System.out.print("Enter a number: ");
int number = scanner.nextInt();
int sum = 0;
// Find divisors and calculate sum
for (int i = 1; i < number; i++) {
if (number % i == 0) {
sum += i;
}
}
// Check if the number is perfect
if (sum == number && number != 0) {
System.out.println(number + " is a perfect number.");
} else {
System.out.println(number + " is not a perfect number.");
}
scanner.close();
}
}
14. Write a program to input two numbers and find the value of one number
raised to the power of another.
import java.util.Scanner;
public class PowerCalculator {
public static void main(String[] args) {
// Create Scanner object
Scanner scanner = new Scanner(System.in);
// Input base number
System.out.print("Enter the base number: ");
double base = scanner.nextDouble();
// Input exponent number
System.out.print("Enter the exponent: ");
double exponent = scanner.nextDouble();
// Calculate power using Math.pow()
double result = Math.pow(base, exponent);
// Display result
System.out.println(base + " raised to the power of " + exponent + " is: " +
result);
scanner.close();
}
}
15. Write a program to display the table of a number entered by the user.
import java.util.Scanner;
public class TableDisplay {
public static void main(String[] args) {
// Create Scanner object to take user input
Scanner scanner = new Scanner(System.in);
// Prompt user for input
System.out.print("Enter a number to display its table: ");
int number = scanner.nextInt();
// Display the multiplication table from 1 to 10
System.out.println("Multiplication Table of " + number + ":");
for (int i = 1; i <= 10; i++) {
System.out.println(number + " x " + i + " = " + (number * i));
}
// Close the scanner
scanner.close();
}
}
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 java.util.Scanner;
public class AreaCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int choice;
// Menu loop
do {
System.out.println("\n--- Area Calculator ---");
System.out.println("1. Area of Circle");
System.out.println("2. Area of Rectangle");
System.out.println("3. Area of Square");
System.out.println("4. Area of Triangle");
System.out.println("5. Exit");
System.out.print("Enter your choice (1-5): ");
choice = scanner.nextInt();
switch (choice) {
case 1: // Circle
System.out.print("Enter radius of the circle: ");
double radius = scanner.nextDouble();
double areaCircle = Math.PI * radius * radius;
System.out.println("Area of Circle = " + areaCircle);
break;
case 2: // Rectangle
System.out.print("Enter length of the rectangle: ");
double length = scanner.nextDouble();
System.out.print("Enter breadth of the rectangle: ");
double breadth = scanner.nextDouble();
double areaRectangle = length * breadth;
System.out.println("Area of Rectangle = " + areaRectangle);
break;
case 3: // Square
System.out.print("Enter side of the square: ");
double side = scanner.nextDouble();
double areaSquare = side * side;
System.out.println("Area of Square = " + areaSquare);
break;
case 4: // Triangle
System.out.print("Enter base of the triangle: ");
double base = scanner.nextDouble();
System.out.print("Enter height of the triangle: ");
double height = scanner.nextDouble();
double areaTriangle = 0.5 * base * height;
System.out.println("Area of Triangle = " + areaTriangle);
break;
case 5: // Exit
System.out.println("Exiting the program. Goodbye!");
break;
default:
System.out.println("Invalid choice. Please enter a number between 1 and
5.");
}
} while (choice != 5);
scanner.close();
}
}
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 java.util.Scanner;
public class ElectricityBillCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input units consumed
System.out.print("Enter the number of units consumed: ");
int units = sc.nextInt();
double bill = 0;
// Calculate bill based on slabs
if (units <= 100) {
bill = units * 2;
} else if (units <= 200) {
bill = 100 * 2 + (units - 100) * 3;
} else if (units <= 400) {
bill = 100 * 2 + 100 * 3 + (units - 200) * 4;
} else {
bill = 100 * 2 + 100 * 3 + 200 * 4 + (units - 400) * 5;
}
// Display result
System.out.println("Total electricity bill: ₹" + bill);
sc.close();
}
}
18. Write a program to input the month number and print the name of the
month accordingly.
import java.util.Scanner;
public class MonthName {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Input the month number
System.out.print("Enter the month number (1-12): ");
int monthNumber = scanner.nextInt();
// 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
System.out.println(monthName);
scanner.close();
}
}
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 java.util.Scanner;
public class FibonacciSeries {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in); // Create a Scanner object
System.out.print("Enter the number of terms: ");
int n = scanner.nextInt(); // Read user input
int first = 0, second = 1;
System.out.print("Fibonacci Series up to " + n + " terms: ");
for (int i = 1; i <= n; i++) {
System.out.print(first + " ");
// compute the next term
int next = first + second;
first = second;
second = next;
}
scanner.close(); // Close the scanner
}
}
20. WAP to generate the following patterns using iteration statements.
* 54321
*# 5432
*#* 543
*#*# 54
*#*#* 5
import java.util.Scanner;
public class PatternGenerator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input for number of rows
System.out.print("Enter number of rows (suggested 5): ");
int n = sc.nextInt();
// Outer loop for each row
for (int i = 0; i < n; i++) {
// Left side pattern: alternating * and #
for (int j = 0; j <= i; j++) {
if (j % 2 == 0) {
System.out.print("* ");
} else {
System.out.print("# ");
}
}
// Spaces between left and right triangle (optional for alignment)
for (int s = 0; s < (n - i - 1) * 2; s++) {
System.out.print(" ");
}
// Right side pattern: descending numbers
for (int k = n - i; k >= 1; k--) {
System.out.print(k + " ");
}
// New line after each row
System.out.println();
}
sc.close();
}
}
Bibliography
Book : Logix Computer Applications
Publisher: KIPS
Internet:
https://www.javatpoint.comhttps://programiz.comhttps://blackbox.
ai.com