Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
92 views

My Class 10 Icse Computer File

Uploaded by

keshav0716kp
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

My Class 10 Icse Computer File

Uploaded by

keshav0716kp
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

ST.

JOHN’S SCHOOL
UPSIDC,FIROZABAD

JAVA
PROGRAMMING

Here is where this template

SUBJECT:COMPUTER
begins

APPLICATIONS

SESSION: 2024-25

SUBMITTED TO: Mr. Krishnakant Upadhyay


SUBMITTED BY: Keshav Pal
class: X section: B
acknowledgem
nt
I Acknowledge my sincere thanks and express my words of
gratitude to principal Rev Fr Joseph Rodriggues who gave me the
golden opportunity to study in this institution and do my research
to accomplish my studies. My sincere thanks to the subject teacher
Mr. Krishnakant Upadhyay, who guided me to do this wonderful
project on the topic Java Programming. He also encouraged and
helped me to complete the project systematically. I thank the
librarian and all the staff members of St. John’s School, UPSIDC,
for their help received throughout my studies here in the school.
This project work helped me to do a lot of research and know more
about the subject. It taught me new things which will be great help
for my future.
I would also like to thank my parents and friends who helped me a
lot in finalizing this project within the limited time frame
Thank you.
___________
Keshav Pal
Certificate

This is to certify that


Keshav Pal of class X B
has successfully completed
his project in
Computer Applications
on the topic
“Java Programming”
Under the guidance of
Mr. Krishnakant Upadhyay
_______ _______ _______
_______ _______ _______
Principal External Internal
examiner examiner
Program 1

Write a menu driven program


using overloading
method,palindrome()to do the
following
a. Void palindrome(String)
b. Void palindrome(int)
• Import java.util.*;
Public class palindrome
{
void main()
{
Scanner sc=new Scanner(System.in);
System.out.println(“ What would you like to
choose”);
Int a=sc.nextInt();
Switch(a)
{
case1:
System.out.println(“Enter a string”);
string s=sc.nextLine();
sc.palindrome(s);
Break;
case 2:
System.out.println(“Enter a no.”);
Int n= sc.nextInt();
Sc.palindrome(n);
Break;
}
}
Void palindrome(Stirng s)
{
string rev = “”;
For(int i=0; i<s.length();i++)
{
rev= s.charAt(i) + rev;
}
If (rev.equalsIgnoreCase(s))
{
System.out.println(“Wor is palindrome”);
Else
{ System .out.println(“Word is not palindrome”);
}
}
}
Program 2

Design a class to overload a function


check( ) as follows:
void check (String str , char ch ) — to find
and print the frequency of a character in a
string.
void check(String s1) — to display only
vowels from string s1, after converting it to
lower case.
Class overloading_String
{
public static void main (String str , char ch)
{ int count =0,I;
For(i=0 ; i<str.length();i++) {
if (ch ==str.charAt(i))
count++;
}
System.out.println(“Number of” + ch + “ present is
= “ + count);
}
Public static void check(String s1) {
Char ch; int I;
S1=s1.toLoweCase();
For(i=0 ; I < s1.length(); i++)
{
ch = s1.charAt(i);
If (ch== ‘a’ || ch==‘e’ || ch ==‘i’ || ch ==‘0’ || ch
== ‘u’)
{ system.out.println(ch + “ “); }
}
}
Public static void main()
{
Overload_string ob= new Overload_string();
Ob.check(“India is my country” , ‘I’);
Ob.check(“republic Day”);
}
}
Program 3

Write a program to input


and check whether it is an
Automorphic or not.
Import java.util.*;
Public class automorphic
{
Public static void main(String Args[])
{
Scanner sc =new scanner (System.in);
System.out.println(“Input a no. :”);
Int num = sc.nextInt();
Int sq_num = num*num;
String str_num = integer.to String(sq_num);
String square =Integer.toString (sq_num);
If(square.endswith(str_num))
system.out.println(“No. is automorphic”);
Else
System.out.println(“No. is not automaorphic”);
}
}
}
Program 4

Define a class Bill as described below:


Class name : Bill
Data Members
Name : to store the name of the
consumer
Cons_no : to store the consumer
number
Unit_con : to store the unit
consumed
Member Methods
Void getdata()
Void compute()
Units
Rate
Up to 120 units
Rs.1.20
More than 120 and up to 250 units
Rs.2.20
More than 250 and up to 400 units
Rs.3.20
Above 400 units
Rs .4.00
Void display()
Import java.util.*;
Public class bill
{
string name;
Int cons_no,unit;
Void getdata()
{
Scanner sc=new Scanner(Sysytem.in);
System.out.println(“Enter name of costumer”);
n= sc.nextLine();

System.out.print(“ enter coustomer no.”);


Cous no = sc.nextInt();
System.out.println(“enter unit consumed”);
Unit_con = sc.nextInt();
}
Void compute()
{
If (unit_con < 120)
double bill = unit_con*1.20;
}
Else if( unit_con>=120&&unit_con<=250)
{
bill = unit_con*2.20;
}
Else if(unit_con>250&&unit_con=400)
{
Bill = unit_con*3.20;
}
Bill = unit_con*4.00;
}
Void display()
{
System.out.println(name);
System.out.println(cons_no);
System.out.println(“unit_con);
}
Void main()
(
Bill ob= new biller;
Obof.get data()
Ob of.compute();
Obof.display();
}
}
Program 5
Create a class salesman to do the
following
Data Members
Sname
Sales
Rate
Tot__amt
Methods
Salesman()
Void input()
Void compute()
Void display()
import.java.util.*;
Public class salesman
{
string sname;
Double sale;
Double rate;
Double tot_amt;
Salesman()
{
sname = “”;
Sales=0.0;
Rate = 0.0;
Tot_amt = 0.0;
}
Void input()
{
system.out.println(“Enter name of sales”);
sname = sc.nexLine();
System.out.println(“Enter the rate per quantity”);
Rate = sc.nextDouble();
}
Void compute()
{
Tot_amt= sales*rate;
}
Void display ()
{
system.out.println(sname);
system.out.println(sales);
system.out.println(rate);
System.out.println(tot_amt);
}
Void main()
{
Salesman ob= new Salesman();
Ob.Input();
Ob.copute();
Ob.display();
}
}
Program 6
Write a program to input
name and marks of 15
students in 2 single-
dimensional arrays. And
print the name and marks
of students rank-wise.
import java.util.*;
class bubblesort
{
public static void main()
{
Scanner sc=new Scanner (System.in);
int i,j,tempmarks;
String tempname;
String name[]=new String[15];
int marks[]=new int[15];
for(i=0;i<15;i++)
{
System.out.print("Enter name of student"+
(i+1)+":");
name[i]=sc.next();
System.out.print("Enter Marks:");
marks i=sc.nextInt();
for(i=0;i<14;i++)
{
for(j=i+1;j<15;j++)
{
if(marks[i]<marks[j])
{
tempmarks=marks[i];
marks[i]=marks[j];
marks [j]=tempmarks;
tempname=name[i];
name[i]=name[j];
name[j]=tempname;
}
}
}
System.out.println("Name and Marks of Students
Rankwise");
System.out.println("Name Marks");
for(i=0;i<15;i++)
System.out.println(name[i]+" "+marks[i]);
}
}
}
Program 7

W rite a program to input


elements in an array of
size m x m and print the sum
of left diagonal and
product of the right diagonal.
import java.util.*;
class array_double_diagonal
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int i,j,m,s1=0,pr=1;
System.out.println("Enter the size:");
m=sc.nextInt();
int ar[][]=new int[m][m];
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
System.out.print("Enter a number:");
ar[i][j]=sc.nextInt();
}
}
System.out.println("Original Array:");
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
System.out.print(ar[i][j]+" ");
}
System.out.println();
}
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
{
if(i==j)
{
s1=s1+ar[i][j];
}
if((i+j)==(m-1))
{
pr=pr*ar[i][j];
}
}
}
System.out.println("Sum of left diagonal:" + s1);
System.out.println("Product of right diagonal:" + pr);
}
}
Program 8

Write a program to input a


number to search and
print whether the number
is present in the array or
not.
import java .util.*;
class BinarySearch
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int a[]={5,7,9,11,15,20,30,45,89,97};
int es,min=0,max=a.length-1,mid=-1,pos=-1;
System.out.print("Elements to Search:");
es=sc.nextInt();
while(min<=max)
{
mid=(min+max)/2;
if(es==a[mid])
{
pos=mid; break;
}
else if(es<a[mid])
max=mid-1;
else
min=mid+1;
}
if(pos!=-1)
System.out.println(es+"found at index "+mid);
else
System.out.println("Search element not found");
}
}
Program 9
Write a program to input 10
numbers in an array and a
number to search and print
whether the number is
present in array or not.
import java.util.*;
class linear_search
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int ar[]=new int[10];
int n,i,p=-1;
for(i=0;i<10;i++)
{
System.out.print("Enter a number:");
ar[i]=sc.nextInt();
}
System.out.print("Enter a number to search:");
n=sc.nextInt();
for(i=0;i<10;i++)
{
if(ar[i]==n)
{
p=i;
break;
}
}
if(p!= -1)
System.out.println(n+"found in index"+p);
else
System.out.println(n+"not found");
}
}
Program 10

Write a program to input 10


numbers in an array and
sort the numbers in
descending order.
import java.util.*;
class Seletion_sort
{
public static void main()
{
Scanner sc=new Scanner(System.in);
int ar[]=new int[10];
int i,j,temp,min,minpos=-1;
for(i=0;i<10;i++)
{
System.out.print("Enter a number");
ar[i]=sc.nextInt();

}
for(i=0;i<9;i++)
{
min=ar[i];
minpos=i;
for(j=i+1;j<10;j++)
{
if(ar[j]<min)
{
min=ar[j];
}
temp=ar[minpos];
ar[minpos]=ar[i];
ar[i]=temp; }
for(i=0;i<10;i++)
{
System.out.print(ar[i]+" ");
}
}
}
}
Program 11
Write a program to input a
sentence ,and convert the
small letters to capital letters
and vice versa.
import java.util.*;
class word_count
{
public static void main()
{
Scanner sc=new Scanner(System.in);
String str,newstr="";
int i,l,cw=0;
char ch,ch1;
System.out.println("Enter a sentence");
str=sc.nextLine();
l=str.length();
for(i=0;i<1;i++)
{
ch=str.charAt (i);
if(ch>='A'&& ch<='Z')
ch1=(char)(ch+32);
else
if(ch>'a'&& ch<='z')
ch1=(char)(ch-32);
else
ch1=ch;
newstr=newstr+ch1;
}
System.out.println("Old String:"+str);
System.out.println("Converted string :"+newstr);
}
}
Program 12

Write a program to input


full name of a person and
print its abbreviated form.
import java.util.*;
class abbreviate
{
public static void main()
{
Scanner sc= new Scanner(System.in);
String str,newstr="";
int i,l,sp;
char ch;
System.out.print("Enter name");
str=sc.nextLine();
str=""+str;
l=str.length();
sp=str.lastIndexOf(' ');
for(i=0;i<sp;i++)
{
ch=str.charAt(i);
if(ch==' ')
newstr=newstr+str.substring(sp+1);
System.out.println("Original Name:"+str);
System.out.println("Abbreviated
Name :"+newstr);
}
}
}
Program 13

Write a program to input


a sentence and create a
new sentence after
encoding the sentence in
the following format. If
the character is a vowel
,then replace it with the
next character else the
character is same.
import java.util.*;
class encode
{
public static void main()
{
Scanner sc=new Scanner(System.in);
String str,wd="",encodestr="";
int i,l;
char ch;
System.out.print("Enter a sentence ");
str=sc.nextLine();
str=str+" ";
str=str.toUpperCase();
l=str.length();
for(i=0;i<1;i++)
{
ch=str.charAt(i);
if(ch!=' ')
{
if(ch=='A' || ch='E' || ch=='I' || ch=='O' ||
ch=='U')
wd=wd+(char)(ch+1);
else
wd=wd+ch;
}
else
{
encodestr=encodestr+wd+" ";
wd="";
}
}
System.out.println("Encoded
Sentence:"+encodestr);
}
}
Program 14

Write a program to create a menu driven


program to input a word and using
User’s choice print the following pattern.
Input:COMPUTER
Choice 1: Choice:2

C R
CO ER
COM TER
COMP UTER
COMPU PUTER
COMPUT MPUTER
COMPUTE
OMPUTER
COMPUTER
COMPUTER
import java.util.*;
class pattern_choice
{
public static void main()
{
Scanner sc=new Scanner (System.in);
String wd,extwd;
int i,l,j,ch;
System.out.print("Enter a word ");
wd=sc.next();
wd=wd.toUpperCase();
l=wd.length();
System.out.println("Enter 1 for pattern 1/ 2 for
pattern 2");
ch=sc.nextInt();
switch(ch)
{
case 1:
for(i=0;i<1;i++)
{
extwd=wd.substring(0,i+1);
System.out.println(extwd);
}
break;
case2:
for(j=i;j<1;j++)
{
extwd=extwd+wd.charAt(j);
}
System.out.println(extwd);
}
break;
default: System.out.println("Wrong choice");
}
}
Program 15
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
import java.util.Scanner;
public class SevenWonders
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String[] w = { "CHICHEN ITZA", "CHRIST THE
RDEEEMER", "TAJMAHAL", "GREAT WALL OF CHINA",
"MACHU PICCHU", "PETRA", "COLOSSEUM" };
String[] l = { "MEXICO", "BRAZIL", "INDIA", "CHINA",
"PERU", "JORDAN", "ITALY" };

System.out.print("Enter name of the country: ");


String ch = sc.next();
int index = -1;
for (int i = 0; i < l.length; i++)
{
if (l[i].equals(ch))
{
index = i;
}
}
if (index != -1) {
System.out.println(l[index] + " - " + w[index]);
}
Else
{
System.out.println("Sorry Not Found!");
}
}
}
Program 16
Design a class to overload a
function Joystring( ) as
follows: void Joystring(String s,
char ch1, char ch2) with one
string argument and two
character arguments that
replaces the character argument
ch1 with the character argument
ch2 in the given String s and
prints the new string.
class Overload_function
{
void joyString(String s, char ch1,char ch2)
{
s=s.replace(ch1,ch2);
System.out.println(s);
}
void joyString(String s)
{
int f,l;
f=s.indexOf(' ');
l=s.lastIndexOf(' ');
System.out.println("First index:"+f);
System.out.println("Last index:"+l);
}
void joyString(String s1,String s2)

{
String s=s1+" "+s2;
System.out.println(s);
}
}
Program 17

Write a Java program to accept a


string. Convert the string to
uppercase. Count and output the
number of double letter sequences
that exist in the string.
import java.util.*;
class consequtive
{
public static void main()
{
Scanner sc=new Scanner(System.in);
String str;
int len,c=0,i;
char ch1,ch2;
System.out.println("Enter a number");
str=sc.nextLine();
len=str.length();
for(i=0;i<len-1;i++)
{
ch1=str.charAt(i);
ch2=str.charAt(i+1);

if(Character.isLetter(ch1)&&Character.isLetter(ch2)&&(c
h1==ch2))
{
c++;
}
}
System.out.println(c);
}
}
Program 18

Using the switch statement,


write a menu driven program for
the following:
(a) To print the Floyd's triangle:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(b) To display the following
pattern:
I
IC
ICS
ICSE
import java.util.*;
class Choice
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter your choice\n1-Floyd's
triangle\n2-pattern");int n=sc.nextInt();
switch(n)
{
case 1:int a=1;
for(int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
System.out.print(a++ +" ");
System.out.println();
}
break;
case 2:String s="ICSE";
for(int i=0;i<=4;i++)
{
System.out.println(s.substring(0,i));
}
break;
default:System.out.println("Invalid choice");
}
}
}
Program 19
Using the switch statement, write
a menu driven program for the
following:
(a) To print the Floyd's triangle:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(b) To display the following
pattern:
I
IC
ICS
ICSE
Pattern 1:
public class pattern1{
public static void main(String[] args) {
for(int i =1; i<=5; i++){
for(int j = 1; j<=i; j++){
if(j%2 == 0){
System.out.print("# ");
}
else
{
System.out.print("* ");
}
}
System.out.println();
}
}
}
Pattern 2:
public class pattern2
{
public static void main(String[] args)
{
for(int i =1; i<=5; i++)
{
for(int j = 5; j>=i; j--)
{ System.out.print(j+" ");
}
System.out.println();
}
}
}
Program 20

Define a class Employee having the


following description:
Class name : Employee
Calculate tax based on the given
conditions and display the output
as per the given format.
import java.util.Scanner;
class Employee{
int pan;
String name;
double taxincome;
double tax;
void input()
{
Scanner sc = new Scanner(System.in);
System.out.println ("Enter the name:");
name = sc.nextLine();
System.out.println ("Enter the pan number:");
pan= sc.nextInt();
System.out.println ("Enter your taxable income:");
taxincome= sc.nextDouble();
}
void cal()
{
if(taxincome<=250000.0)
tax=0.0;
if(taxincome>250000.0 && taxincome<=500000.0)
tax= 10.0/100.0*(taxincome-250000.0);
if(taxincome>500000.0 && taxincome <=1000000.0)
tax= 30000.0+20.0/100.0*(taxincome-500000.0);
}
void display(){
System.out.println ("Name:"+name);
System.out.println ("PAN number of the
employee:"+pan);
System.out.println ("Taxable income of the
employee:"+taxincome);
System.out.println ("Tax payable by the
employee:"+tax);
}
void main(){
Employee ob = new Employee();
ob.input();
ob.cal();
ob.display();
}
}
Bibliography

www.github.com
www.brainly.com
Touch pad computer application I.C.S.E class
10th
www.discord.com

You might also like