0% found this document useful (0 votes)
1 views33 pages

ISC Class 12 Java Project Perfect Layout

The document outlines a series of Java programs designed for an ISC Class XII Computer Science practical project, covering various number and string manipulations. Each program includes objectives, code snippets, and example outputs for tasks such as checking Armstrong numbers, palindromes, and sorting words in a sentence. The document serves as a practical guide for students to implement and understand fundamental programming concepts.

Uploaded by

ankitsuper51
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views33 pages

ISC Class 12 Java Project Perfect Layout

The document outlines a series of Java programs designed for an ISC Class XII Computer Science practical project, covering various number and string manipulations. Each program includes objectives, code snippets, and example outputs for tasks such as checking Armstrong numbers, palindromes, and sorting words in a sentence. The document serves as a practical guide for students to implement and understand fundamental programming concepts.

Uploaded by

ankitsuper51
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Table of Contents

Program 1 Armstrong Number Check •

Program 2 Palindrome Number Check •

Program 3 Prime Number Check •

Program 4 Generate Prime Numbers Between Two Given Numbers •

Program 5 Perfect Number Check •

Program 6 Buzz Number Check •

Program 7 Disarium Number Check •

Program 8 Automorphic Number Check •

Program 9 Neon Number Check •

Program 10 Sum of Digits, Reverse, and Frequency of Each Digit •

Program 11 Check Whether a String is a Palindrome •

Program 12 Count Vowels, Consonants, Digits, and Special Characters •

Program 13 Reverse Every Word of a Sentence •

Program 14 Arrange Words of a Sentence in Alphabetical Order •

Program 15 Find the Longest and Shortest Word in a Sentence •

Program 16 Count the Occurrence of Each Word in a Sentence •

Program 17 Encrypt or Decrypt a String Using a Simple Cipher •

Program 18 Remove Duplicate Characters From a String •

Program 19 Convert a Sentence to Title Case •

Program 20 Check Whether Two Strings Are Anagrams •

Program 21 Find Largest, Smallest, and Second Largest Element in an Array •

Program 22 Sort an Array Using Selection Sort •

Program 23 Sort an Array Using Bubble Sort •

ISC Class XII Computer Science Practical Project File 2


Program 24 Search an Element Using Binary Search •

Program 25 Merge Two Sorted Arrays Into One Sorted Array •

Program 26 Store Names and Marks of Students and Display in Descending Order of Marks •

Program 27 Create a Class to Calculate Electricity Bill Using Slabs •

Program 28 Create a Class to Prepare a Bank Account With Deposit, Withdrawal, and Balance •
Methods

Program 29 Create a Class for Employee Salary Calculation Including DA, HRA, and Gross Salary •

Program 30 Create a Class to Generate a Library Fine Based on the Number of Late Days •

ISC Class XII Computer Science Practical Project File 3


Program 1: Armstrong Number Check
Objective: Program to check whether a given number is an Armstrong number (sum of digits raised to the power of
number of digits equals the number).

import [Link];

public class ArmstrongNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
int temp = num, sum = 0, digits = 0;

while (temp > 0) {


digits++;
temp /= 10;
}

temp = num;
while (temp > 0) {
int rem = temp % 10;
sum += [Link](rem, digits);
temp /= 10;
}

if (sum == num) {
[Link](num + " is an Armstrong Number.");
} else {
[Link](num + " is not an Armstrong Number.");
}
}
}

BlueJ: Terminal Window - Program_1

Options

Enter a number: 153


153 is an Armstrong Number.

ISC Class XII Computer Science Practical Project File 4


Program 2: Palindrome Number Check
Objective: Program to check whether a number remains the same when its digits are reversed.

import [Link];

public class PalindromeNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
int temp = num, rev = 0;

while (temp > 0) {


int rem = temp % 10;
rev = rev * 10 + rem;
temp /= 10;
}

if (rev == num) {
[Link](num + " is a Palindrome Number.");
} else {
[Link](num + " is not a Palindrome Number.");
}
}
}

BlueJ: Terminal Window - Program_2

Options

Enter a number: 121


121 is a Palindrome Number.

ISC Class XII Computer Science Practical Project File 5


Program 3: Prime Number Check
Objective: Program to check whether a given number is Prime (divisible only by 1 and itself).

import [Link];

public class PrimeNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
int count = 0;

for (int i = 1; i <= num; i++) {


if (num % i == 0) {
count++;
}
}

if (count == 2) {
[Link](num + " is a Prime Number.");
} else {
[Link](num + " is not a Prime Number.");
}
}
}

BlueJ: Terminal Window - Program_3

Options

Enter a number: 17
17 is a Prime Number.

ISC Class XII Computer Science Practical Project File 6


Program 4: Generate Prime Numbers Between Two Given Numbers
Objective: Program to print all prime numbers within user-defined lower and upper boundaries.

import [Link];

public class PrimeGenerator {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter lower limit: ");
int lower = [Link]();
[Link]("Enter upper limit: ");
int upper = [Link]();

[Link]("Prime numbers between " + lower + " and " + upper + " are:");
for (int i = lower; i <= upper; i++) {
int count = 0;
for (int j = 1; j <= i; j++) {
if (i % j == 0) {
count++;
}
}
if (count == 2) {
[Link](i + " ");
}
}
[Link]();
}
}

BlueJ: Terminal Window - Program_4

Options

Enter lower limit: 10


Enter upper limit: 30
Prime numbers between 10 and 30 are:
11 13 17 19 23 29

ISC Class XII Computer Science Practical Project File 7


Program 5: Perfect Number Check
Objective: Program to check if the sum of proper factors of a number equals the number itself.

import [Link];

public class PerfectNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
int sum = 0;

for (int i = 1; i < num; i++) {


if (num % i == 0) {
sum += i;
}
}

if (sum == num) {
[Link](num + " is a Perfect Number.");
} else {
[Link](num + " is not a Perfect Number.");
}
}
}

BlueJ: Terminal Window - Program_5

Options

Enter a number: 28
28 is a Perfect Number.

ISC Class XII Computer Science Practical Project File 8


Program 6: Buzz Number Check
Objective: Program to check if a number ends with 7 or is divisible by 7.

import [Link];

public class BuzzNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();

if (num % 7 == 0 || num % 10 == 7) {
[Link](num + " is a Buzz Number.");
} else {
[Link](num + " is not a Buzz Number.");
}
}
}

BlueJ: Terminal Window - Program_6

Options

Enter a number: 57
57 is a Buzz Number.

ISC Class XII Computer Science Practical Project File 9


Program 7: Disarium Number Check
Objective: Program to check if the sum of its digits powered with their respective positions equals the number.

import [Link];

public class DisariumNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();

String s = [Link](num);
int len = [Link]();
int temp = num, sum = 0;

while (temp > 0) {


int rem = temp % 10;
sum += [Link](rem, len);
len--;
temp /= 10;
}

if (sum == num) {
[Link](num + " is a Disarium Number.");
} else {
[Link](num + " is not a Disarium Number.");
}
}
}

BlueJ: Terminal Window - Program_7

Options

Enter a number: 135


135 is a Disarium Number.

ISC Class XII Computer Science Practical Project File 10


Program 8: Automorphic Number Check
Objective: Program to check if a number's square ends with the same digits as the number itself.

import [Link];

public class AutomorphicNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
int sq = num * num;

String s1 = [Link](num);
String s2 = [Link](sq);

if ([Link](s1)) {
[Link](num + " is an Automorphic Number.");
} else {
[Link](num + " is not an Automorphic Number.");
}
}
}

BlueJ: Terminal Window - Program_8

Options

Enter a number: 25
25 is an Automorphic Number.

ISC Class XII Computer Science Practical Project File 11


Program 9: Neon Number Check
Objective: Program to check if the sum of digits of the square of a number is equal to the number itself.

import [Link];

public class NeonNumber {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
int sq = num * num;
int sum = 0;

while (sq > 0) {


sum += sq % 10;
sq /= 10;
}

if (sum == num) {
[Link](num + " is a Neon Number.");
} else {
[Link](num + " is not a Neon Number.");
}
}
}

BlueJ: Terminal Window - Program_9

Options

Enter a number: 9
9 is a Neon Number.

ISC Class XII Computer Science Practical Project File 12


Program 10: Sum of Digits, Reverse, and Frequency of Each Digit
Objective: Program to process a number to calculate digit sum, its reverse, and individual digit counts.

import [Link];

public class DigitAnalysis {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a number: ");
int num = [Link]();
int temp = num, sum = 0, rev = 0;
int[] freq = new int[10];

while (temp > 0) {


int rem = temp % 10;
sum += rem;
rev = rev * 10 + rem;
freq[rem]++;
temp /= 10;
}

[Link]("Sum of digits: " + sum);


[Link]("Reverse of number: " + rev);
[Link]("Digit Frequencies:");
for (int i = 0; i < 10; i++) {
if (freq[i] > 0) {
[Link](i + " occurs " + freq[i] + " time(s)");
}
}
}
}

BlueJ: Terminal Window - Program_10

Options

Enter a number: 5452


Sum of digits: 16
Reverse of number: 2545
Digit Frequencies:
2 occurs 1 time(s)
4 occurs 1 time(s)
5 occurs 2 time(s)

ISC Class XII Computer Science Practical Project File 13


Program 11: Check Whether a String is a Palindrome
Objective: Program to verify if a string reads identically forward and backward, ignoring lower/uppercase.

import [Link];

public class StringPalindrome {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a string: ");
String str = [Link]();
String rev = "";

for (int i = [Link]() - 1; i >= 0; i--) {


rev += [Link](i);
}

if ([Link](rev)) {
[Link]("The string is a Palindrome.");
} else {
[Link]("The string is not a Palindrome.");
}
}
}

BlueJ: Terminal Window - Program_11

Options

Enter a string: Madam


The string is a Palindrome.

ISC Class XII Computer Science Practical Project File 14


Program 12: Count Vowels, Consonants, Digits, and Special Characters
Objective: Program to parse a string and quantify elements based on ISC standard character evaluation criteria.

import [Link];

public class CharacterCounter {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a string: ");
String str = [Link]().toLowerCase();
int v = 0, c = 0, d = 0, s = 0;

for (int i = 0; i < [Link](); i++) {


char ch = [Link](i);
if (ch >= 'a' && ch <= 'z') {
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
v++;
} else {
c++;
}
} else if (ch >= '0' && ch <= '9') {
d++;
} else {
s++;
}
}
[Link]("Vowels: " + v + ", Consonants: " + c);
[Link]("Digits: " + d + ", Special Characters: " + s);
}
}

BlueJ: Terminal Window - Program_12

Options

Enter a string: Java 123!


Vowels: 2, Consonants: 2
Digits: 3, Special Characters: 2

ISC Class XII Computer Science Practical Project File 15


Program 13: Reverse Every Word of a Sentence
Objective: Program to parse sentences, extract words, and reverse their underlying constituent components
individually.

import [Link];

public class ReverseWords {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence: ");
String str = [Link]();
String[] words = [Link](" ");
String result = "";

for (int k = 0; k < [Link]; k++) {


String w = words[k];
String revW = "";
for (int i = [Link]() - 1; i >= 0; i--) {
revW += [Link](i);
}
result += revW + " ";
}
[Link]("Result: " + [Link]());
}
}

BlueJ: Terminal Window - Program_13

Options

Enter a sentence: BLUEJ IS FUN


Result: JEULB SI NUF

ISC Class XII Computer Science Practical Project File 16


Program 14: Arrange Words of a Sentence in Alphabetical Order
Objective: Standard loop-based comparative bubble swap sorting applied strictly on string array instances.

import [Link];

public class AlphabeticalWords {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence: ");
String str = [Link]();
String[] words = [Link](" ");

for (int i = 0; i < [Link] - 1; i++) {


for (int j = 0; j < [Link] - 1 - i; j++) {
if (words[j].compareToIgnoreCase(words[j + 1]) > 0) {
String temp = words[j];
words[j] = words[j + 1];
words[j + 1] = temp;
}
}
}

[Link]("Sorted Words:");
for (int i = 0; i < [Link]; i++) {
[Link](words[i] + " ");
}
[Link]();
}
}

BlueJ: Terminal Window - Program_14

Options

Enter a sentence: java bluej apple cat


Sorted Words:
apple bluej cat java

ISC Class XII Computer Science Practical Project File 17


Program 15: Find the Longest and Shortest Word in a Sentence
Objective: Linear array scan mapping string length constraints to pull extrema indices.

import [Link];

public class WordLengthAnalysis {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence: ");
String str = [Link]();
String[] words = [Link](" ");

String longest = words[0], shortest = words[0];


for (int i = 1; i < [Link]; i++) {
if (words[i].length() > [Link]()) {
longest = words[i];
}
if (words[i].length() < [Link]()) {
shortest = words[i];
}
}
[Link]("Longest Word: " + longest);
[Link]("Shortest Word: " + shortest);
}
}

BlueJ: Terminal Window - Program_15

Options

Enter a sentence: Programming in Java language


Longest Word: Programming
Shortest Word: in

ISC Class XII Computer Science Practical Project File 18


Program 16: Count the Occurrence of Each Word in a Sentence
Objective: Program tracking match occurrence flags using standard state indicators to avoid counting double
entries.

import [Link];

public class WordOccurrence {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence: ");
String str = [Link]();
String[] words = [Link](" ");
boolean[] visited = new boolean[[Link]];

for (int i = 0; i < [Link]; i++) {


if (visited[i]) continue;
int count = 1;
for (int j = i + 1; j < [Link]; j++) {
if (words[i].equalsIgnoreCase(words[j])) {
count++;
visited[j] = true;
}
}
[Link](words[i] + " : " + count);
}
}
}

BlueJ: Terminal Window - Program_16

Options

Enter a sentence: hello world hello java


hello : 2
world : 1
java : 1

ISC Class XII Computer Science Practical Project File 19


Program 17: Encrypt or Decrypt a String Using a Simple Cipher
Objective: Shifts characters across boundary alphabets to manipulate baseline string data.

import [Link];

public class SimpleCipher {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter text: ");
String text = [Link]();
[Link]("Enter shift key (e.g., 3): ");
int key = [Link]();

String encrypted = "";


for (int i = 0; i < [Link](); i++) {
char ch = [Link](i);
if ([Link](ch)) {
char base = [Link](ch) ? 'A' : 'a';
ch = (char) ((ch - base + key) % 26 + base);
}
encrypted += ch;
}
[Link]("Encrypted text: " + encrypted);
}
}

BlueJ: Terminal Window - Program_17

Options

Enter text: ABC


Enter shift key (e.g., 3): 3
Encrypted text: DEF

ISC Class XII Computer Science Practical Project File 20


Program 18: Remove Duplicate Characters From a String
Objective: Program that outputs characters exclusively if their active storage check shows true novelty metrics.

import [Link];

public class RemoveDuplicates {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a string: ");
String str = [Link]();
String result = "";

for (int i = 0; i < [Link](); i++) {


char ch = [Link](i);
if ([Link](ch) == -1) {
result += ch;
}
}
[Link]("Filtered string: " + result);
}
}

BlueJ: Terminal Window - Program_18

Options

Enter a string: success


Filtered string: suces

ISC Class XII Computer Science Practical Project File 21


Program 19: Convert a Sentence to Title Case
Objective: Isolates and standardizes the capitalization layout of word strings across whitespace divisions.

import [Link];

public class TitleCaseConverter {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter a sentence: ");
String str = [Link]();
String[] words = [Link](" ");
String result = "";

for (int i = 0; i < [Link]; i++) {


String w = words[i];
if ([Link]() > 0) {
result += [Link]([Link](0)) +
[Link](1).toLowerCase() + " ";
}
}
[Link]("Title Case: " + [Link]());
}
}

BlueJ: Terminal Window - Program_19

Options

Enter a sentence: welcome to bluej programming


Title Case: Welcome To Bluej Programming

ISC Class XII Computer Science Practical Project File 22


Program 20: Check Whether Two Strings Are Anagrams
Objective: Verifies identical string compositions by converting inputs into sorted alphanumeric sequence arrays.

import [Link];
import [Link];

public class AnagramCheck {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter first string: ");
String s1 = [Link]().replaceAll("\\s", "").toLowerCase();
[Link]("Enter second string: ");
String s2 = [Link]().replaceAll("\\s", "").toLowerCase();

char[] arr1 = [Link]();


char[] arr2 = [Link]();
[Link](arr1);
[Link](arr2);

if ([Link](arr1, arr2)) {
[Link]("The strings are Anagrams.");
} else {
[Link]("The strings are not Anagrams.");
}
}
}

BlueJ: Terminal Window - Program_20

Options

Enter first string: listen


Enter second string: silent
The strings are Anagrams.

ISC Class XII Computer Science Practical Project File 23


Program 21: Find Largest, Smallest, and Second Largest Element in an Array
Objective: ISC array pattern iterating tracking values to locate secondary maxima constraints.

import [Link];

public class ArrayAnalysis {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter size of array: ");
int n = [Link]();
int[] arr = new int[n];

[Link]("Enter array elements:");


for (int i = 0; i < n; i++) {
arr[i] = [Link]();
}

int largest = Integer.MIN_VALUE;


int second = Integer.MIN_VALUE;
int smallest = Integer.MAX_VALUE;

for (int i = 0; i < n; i++) {


int val = arr[i];
if (val > largest) {
second = largest;
largest = val;
} else if (val > second && val != largest) {
second = val;
}
if (val < smallest) {
smallest = val;
}
}
[Link]("Smallest: " + smallest);
[Link]("Largest: " + largest);
[Link]("Second Largest: " + second);
}
}

BlueJ: Terminal Window - Program_21

Options

Enter size of array: 4


Enter array elements:
12 45 23 89
Smallest: 12
Largest: 89
Second Largest: 45

ISC Class XII Computer Science Practical Project File 24


Program 22: Sort an Array Using Selection Sort
Objective: Classic selection sorting layout built around systematic iterative index exchanges.

import [Link];

public class SelectionSort {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter array size: ");
int n = [Link]();
int[] arr = new int[n];

[Link]("Enter elements:");
for (int i = 0; i < n; i++) {
arr[i] = [Link]();
}

for (int i = 0; i < n - 1; i++) {


int minIdx = i;
for (int j = i + 1; j < n; j++) {
if (arr[j] < arr[minIdx]) {
minIdx = j;
}
}
int temp = arr[minIdx];
arr[minIdx] = arr[i];
arr[i] = temp;
}

[Link]("Sorted array:");
for (int i = 0; i < n; i++) {
[Link](arr[i] + " ");
}
[Link]();
}
}

BlueJ: Terminal Window - Program_22

Options

Enter array size: 4


Enter elements:
50 20 40 10
Sorted array:
10 20 40 50

ISC Class XII Computer Science Practical Project File 25


Program 23: Sort an Array Using Bubble Sort
Objective: Standard adjacent index check bubble architecture for sort structuring.

import [Link];

public class BubbleSort {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter array size: ");
int n = [Link]();
int[] arr = new int[n];

[Link]("Enter elements:");
for (int i = 0; i < n; i++) {
arr[i] = [Link]();
}

for (int i = 0; i < n - 1; i++) {


for (int j = 0; j < n - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
[Link]("Sorted array:");
for (int i = 0; i < n; i++) {
[Link](arr[i] + " ");
}
[Link]();
}
}

BlueJ: Terminal Window - Program_23

Options

Enter array size: 4


Enter elements:
9 3 7 1
Sorted array:
1 3 7 9

ISC Class XII Computer Science Practical Project File 26


Program 24: Search an Element Using Binary Search
Objective: Logarithmic binary slice tracking logic executing matching routine metrics over arrays.

import [Link];

public class BinarySearch {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter size of sorted array: ");
int n = [Link]();
int[] arr = new int[n];

[Link]("Enter sorted elements:");


for (int i = 0; i < n; i++) {
arr[i] = [Link]();
}

[Link]("Enter element to search: ");


int target = [Link]();

int low = 0, high = n - 1, pos = -1;


while (low <= high) {
int mid = (low + high) / 2;
if (arr[mid] == target) {
pos = mid;
break;
} else if (arr[mid] < target) {
low = mid + 1;
} else {
high = mid - 1;
}
}
if (pos != -1) {
[Link]("Element found at index " + pos);
} else {
[Link]("Element not found.");
}
}
}

BlueJ: Terminal Window - Program_24

Options

Enter size of sorted array: 4


Enter sorted elements:
10 20 30 40
Enter element to search: 30
Element found at index 2

ISC Class XII Computer Science Practical Project File 27


Program 25: Merge Two Sorted Arrays Into One Sorted Array
Objective: Synchronized index comparison pointer processing layout to merge sorted structural vectors directly.

import [Link];

public class MergeArrays {


public static void main(String[] args) {
int[] a = {1, 3, 5};
int[] b = {2, 4, 6};
int[] c = new int[[Link] + [Link]];

int i = 0, j = 0, k = 0;
while (i < [Link] && j < [Link]) {
if (a[i] < b[j]) {
c[k++] = a[i++];
} else {
c[k++] = b[j++];
}
}
while (i < [Link]) {
c[k++] = a[i++];
}
while (j < [Link]) {
c[k++] = b[j++];
}

[Link]("Merged Array:");
for (int n = 0; n < [Link]; n++) {
[Link](c[n] + " ");
}
[Link]();
}
}

BlueJ: Terminal Window - Program_25

Options

Merged Array:
1 2 3 4 5 6

ISC Class XII Computer Science Practical Project File 28


Program 26: Store Names and Marks of Students and Display in Descending
Order of Marks
Objective: Parallel structural mapping applying descending values bubble algorithm sorting layout tracking text
entries.

import [Link];

public class StudentRegistry {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter number of students: ");
int n = [Link]();
String[] names = new String[n];
int[] marks = new int[n];

for (int i = 0; i < n; i++) {


[Link]("Enter name of student " + (i+1) + ": ");
names[i] = [Link]();
[Link]("Enter marks: ");
marks[i] = [Link]();
}

for (int i = 0; i < n - 1; i++) {


for (int j = 0; j < n - 1 - i; j++) {
if (marks[j] < marks[j + 1]) {
int tMark = marks[j];
marks[j] = marks[j+1];
marks[j+1] = tMark;

String tName = names[j];


names[j] = names[j+1];
names[j+1] = tName;
}
}
}
[Link]("\nSorted Leaderboard:");
for (int i = 0; i < n; i++) {
[Link](names[i] + " - " + marks[i]);
}
}
}

BlueJ: Terminal Window - Program_26

Options

Enter number of students: 2


Enter name of student 1: Alex
Enter marks: 85
Enter name of student 2: Bob
Enter marks: 95

Sorted Leaderboard:
Bob - 95
Alex - 85

ISC Class XII Computer Science Practical Project File 29


Program 27: Create a Class to Calculate Electricity Bill Using Slabs
Objective: Class architecture implementing structured dynamic conditionals to calculate utilities based on
progressive ranges.

import [Link];

public class ElectricityBill {


private String name;
private int units;
private double bill;

public void input() {


Scanner sc = new Scanner([Link]);
[Link]("Enter Consumer Name: ");
name = [Link]();
[Link]("Enter Units Consumed: ");
units = [Link]();
}

public void calculate() {


if (units <= 100) {
bill = units * 1.5;
} else if (units <= 300) {
bill = 100 * 1.5 + (units - 100) * 2.5;
} else {
bill = 100 * 1.5 + 200 * 2.5 + (units - 300) * 4.0;
}
}

public void display() {


[Link]("Consumer: " + name);
[Link]("Units: " + units);
[Link]("Total Amount Due: Rs. " + bill);
}

public static void main(String[] args) {


ElectricityBill ob = new ElectricityBill();
[Link]();
[Link]();
[Link]();
}
}

BlueJ: Terminal Window - Program_27

Options

Enter Consumer Name: John Doe


Enter Units Consumed: 250
Consumer: John Doe
Units: 250
Total Amount Due: Rs. 525.0

ISC Class XII Computer Science Practical Project File 30


Program 28: Create a Class to Prepare a Bank Account With Deposit,
Withdrawal, and Balance Methods
Objective: Class object with custom methods simulating core balance ledgers.

import [Link];

public class BankAccount {


private double balance = 5000.0;

public void deposit(double amt) {


balance += amt;
[Link]("Deposited: " + amt);
}

public void withdraw(double amt) {


if (amt <= balance) {
balance -= amt;
[Link]("Withdrawn: " + amt);
} else {
[Link]("Insufficient Balance!");
}
}

public void checkBalance() {


[Link]("Current Balance: Rs. " + balance);
}

public static void main(String[] args) {


BankAccount account = new BankAccount();
[Link]();
[Link](1500);
[Link](2000);
[Link]();
}
}

BlueJ: Terminal Window - Program_28

Options

Current Balance: Rs. 5000.0


Deposited: 1500.0
Withdrawn: 2000.0
Current Balance: Rs. 4500.0

ISC Class XII Computer Science Practical Project File 31


Program 29: Create a Class for Employee Salary Calculation Including DA, HRA,
and Gross Salary
Objective: Encapsulated payroll module processing workforce multipliers to map compensation elements.

import [Link];

public class EmployeeSalary {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter Employee Name: ");
String name = [Link]();
[Link]("Enter Base Salary: ");
double base = [Link]();

double da = 0.30 * base;


double hra = 0.15 * base;
double gross = base + da + hra;

[Link]("Payroll Statement for " + name);


[Link]("Basic Pay: Rs. " + base);
[Link]("DA (30%): Rs. " + da);
[Link]("HRA (15%): Rs. " + hra);
[Link]("Gross Salary: Rs. " + gross);
}
}

BlueJ: Terminal Window - Program_29

Options

Enter Employee Name: Sarah


Enter Base Salary: 40000
Payroll Statement for Sarah
Basic Pay: Rs. 40000.0
DA (30%): Rs. 12000.0
HRA (15%): Rs. 6000.0
Gross Salary: Rs. 58000.0

ISC Class XII Computer Science Practical Project File 32


Program 30: Create a Class to Generate a Library Fine Based on the Number of
Late Days
Objective: Dynamic scalar fine calculations tailored to tiered intervals for academic asset handling.

import [Link];

public class LibraryFine {


public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
[Link]("Enter number of late days: ");
int days = [Link]();
double fine = 0;

if (days <= 5) {
fine = days * 1.0;
} else if (days <= 10) {
fine = 5 * 1.0 + (days - 5) * 2.0;
} else {
fine = 5 * 1.0 + 5 * 2.0 + (days - 10) * 5.0;
}

[Link]("Total Library Penalty Fee: Rs. " + fine);


}
}

BlueJ: Terminal Window - Program_30

Options

Enter number of late days: 12


Total Library Penalty Fee: Rs. 25.0

ISC Class XII Computer Science Practical Project File 33

You might also like