Lab Activity Class 10 2025-26 Final
Lab Activity Class 10 2025-26 Final
COMPUTER APPLICATION
CLASS-10
TOPICS
CLASS AS THE BASIS OF ALL COMPUTATION(OBJECTS AND CLASSES)
void input() — To input and store the accession number, title and author.
Void compute() — To accept the number of days late, calculate and display the fine charged at the rate
of Rs. 2 per day.
import java.util.Scanner;
void input() {
Scanner in = new Scanner(System.in);
System.out.print("Enter book title: ");
title = in.nextLine();
System.out.print("Enter author: ");
author = in.nextLine();
System.out.print("Enter accession number: ");
accNum = in.nextInt();
}
void compute() {
Scanner in = new Scanner(System.in);
System.out.print("Enter number of days late: ");
int days = in.nextInt();
int fine = days * 2;
System.out.println("Fine = Rs." + fine);
}
void display() {
System.out.println("Accession Number\tTitle\tAuthor");
System.out.println(accNum + "\t\t" + title + "\t" + author);
}
Member
Purpose
Methods
To display the title of the movie and a message based on the rating as per the table
void display()
given below
Ratings Table
Write a main method to create an object of the class and call the above member methods.
import java.util.Scanner;
public movieMagic() {
year = 0;
title = "";
rating = 0.0f;
}
public void accept() {
Scanner in = new Scanner(System.in);
System.out.print("Enter Title of Movie: ");
title = in.nextLine();
System.out.print("Enter Year of Movie: ");
year = in.nextInt();
System.out.print("Enter Rating of Movie: ");
rating = in.nextFloat();
}
System.out.println(title);
System.out.println(message);
}
Member methods:
(i) BookFair() — Default constructor to initialize data members
(ii) void Input() — To input and store the name and the price of the book.
(iii) void calculate() — To calculate the price after discount. Discount is calculated based on the following criteria.
Price Discount
More than ₹1000 and less than or equal to ₹3000 10% of price
(iv) void display() — To display the name and price of the book after discount.
Write a main method to create an object of the class and call the above member methods.
import java.util.Scanner;
public BookFair() {
bname = "";
price = 0.0;
}
price -= disc;
}
class : ElectricBill
Member methods:
void accept( ) — to accept the name of the customer and number of units consumed
void calculate( ) — to calculate the bill as per the following tariff:
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
Member methods:
void accept() — To take input for name, coach, mobile number and amount.
void update() — To update the amount as per the coach selected (extra amount to be added in the amount as
follows)
First_AC 700
Second_AC 500
Type of Coaches Amount
Third_AC 250
sleeper None
void display() — To display all details of a customer such as name, coach, total amount and mobile number.
Write a main method to create an object of the class and call the above member methods.
import java.util.Scanner;
void display() — To display customer name, mobile number, amount to be paid after discount.
Write a main method to create an object of the class and call the above member methods.
ANS-
import java.util.Scanner;
public ShowRoom()
{
name = "";
mobno = 0;
cost = 0.0;
dis = 0.0;
amount = 0.0;
}
ARRAY
01. Write a program to input 10 integer elements in an array and sort them in descending order using bubble
sort technique.
02.Write a program to input twenty names in an array. Arrange these names in descending order of letters, using
the bubble sort technique.
import java.util.Scanner;
//Bubble Sort
for (int i = 0; i < names.length - 1; i++) {
for (int j = 0; j < names.length - 1 - i; j++) {
if (names[j].compareToIgnoreCase(names[j + 1]) < 0) {
String temp = names[j + 1];
names[j + 1] = names[j];
names[j] = temp;
}
}
}
System.out.println("\nSorted Names");
for (int i = 0; i < names.length; i++) {
System.out.println(names[i]);
}
}
}
03. Write a program to perform binary search on a list of integers given below, to search for an element input by
the user. If it is found display the element along with its position, otherwise display the message "Search element
not found".
if (index == -1) {
System.out.println("Search element not found");
}
else {
System.out.println(n + " found at position " + index);
}
}
}
04. Write a program to input and sort the weight of ten people. Sort and display them in descending order using
the selection sort technique.
import java.util.Scanner;
double t = weightArr[i];
weightArr[i] = weightArr[idx];
weightArr[idx] = t;
}
05. Write a program to accept the names of 10 cities in a single dimensional string array and their STD (Subscribers
Trunk Dialling) codes in another single dimension integer array. Search for the name of a city input by the user in
the list. If found, display "Search Successful" and print the name of the city along with its STD code, or else display
the message "Search unsuccessful, no such city in the list".
import java.util.Scanner;
int idx;
for (idx = 0; idx < SIZE; idx++) {
if (city.compareToIgnoreCase(cities[idx]) == 0) {
break;
}
}
06. Write a program to accept the year of graduation from school as an integer value from the user. Using the
binary search technique on the sorted array of integers given below, output the message "Record exists" if the
value input is located in the array. If not, output the message "Record does not exist".
n[0] n[1] n[2] n[3] n[4] n[5] n[6] n[7] n[8] n[9]
1982 1987 1993 1996 1999 2003 2006 2007 2009 2010
import java.util.Scanner;
if (idx == -1)
System.out.println("Record does not exist");
else
System.out.println("Record exists");
}
}
07.Write a program to initialize the seven Wonders of the World along with their locations in two different arrays.
Search for a name of the country input by the user. If found, display the name of the country along with its
Wonder, otherwise display "Sorry not found!".
Seven Wonders:
CHICHEN ITZA, CHRIST THE REDEEMER, TAJ MAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations:
MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Examples:
Country name: INDIA
Output: TAJ MAHAL
if (i == locations.length)
System.out.println("Sorry Not Found!");
}
}
08.Write a program to input integer elements into an array of size 20 and perform the following operations:
sum += arr[i];
}
09.Define a class to perform binary search on a list of integers given below, to search for an element input by
the user, if it is found display the element along with its position, otherwise display the message "Search
element not found".
if (index == -1) {
System.out.println("Search element not found");
}
else {
System.out.println(n + " found at position " + index);
}
}
}
STRING HANDLING
01. Write a program to accept a word and convert it into lower case, if it is in upper case. Display the new
word by replacing only the vowels with the letter following it.
Sample Input: computer
Sample Output: cpmpvtfr
import java.util.Scanner;
if (str.charAt(i) == 'a' ||
str.charAt(i) == 'e' ||
str.charAt(i) == 'i' ||
str.charAt(i) == 'o' ||
str.charAt(i) == 'u') {
}
else {
newStr = newStr + ch;
}
}
System.out.println(newStr);
}
}
02. Write a program to accept a string. Convert the string into upper case letters. Count and output the
number of double letter sequences that exist in the string.
Sample Input: "SHE WAS FEEDING THE LITTLE RABBIT WITH AN
APPLE" Sample Output: 4
import java.util.Scanner;
}
}
03.Write a program that encodes a word into Piglatin. To translate word into Piglatin word, convert the word into
uppercase and then place the first vowel of the original word as the start of the new word along with the
remaining alphabets. The alphabets present before the vowel being shifted towards the end followed by "AY".
word=word.toUpperCase();
String piglatin="";
int flag=0;
if(flag == 0)
{
piglatin = word + "AY";
}
System.out.println(word + " in Piglatin format is " + piglatin);
}
}
04. Special words are those words which start and end with the same
letter. Example: EXISTENCE, COMIC, WINDOW
Palindrome words are those words which read the same from left to right and vice-
versa. Example: MALYALAM, MADAM, LEVEL, ROTATOR, CIVIC
All palindromes are special words but all special words are not palindromes.
import java.util.Scanner;
if (isPalin) {
System.out.println("Palindrome");
}
else {
System.out.println("Special");
}
}
else {
System.out.println("Neither Special nor Palindrome");
}
}
}
05. Write a program in Java to accept a string in lower case and change the first letter of every word to upper
case. Display the new string.
System.out.println(word);
}
}