Computer Applications Project
Computer Applications Project
Page : 1
digit or a special symbol.
29 18 To see if number is Armstrong or not.
31 19 Bubble sort
33 20 To check frequency of a letter
34 21 To print string without using vowels
35 22 To count non-vowels alphabets in a string
36 23 To enter a name and print its initials
37 24 To print asterisk instead Of vowels
39 25 To print every words first letter
40 26 To Print only Palindrome words in a string
41 27 To print reverse of words in a string
43 28 To print sum of prime digits of a number
44 29 Loop pattern
46 30 To print sum of series of for loop
47 ------------------ Bibliography
Page : 2
I would like to express my special thanks of gratitude to my computer
teacher “Mr. Harvinder Singh” for their able guidance and support in
completing my project.
I would also like to extend my gratitude to the Principle “Mr. Samuel
Jaideep” and Vice Principle “Mr. Ramesh Uniyal ” for providing me with
all the facility that was required.
Date : 27/10/2022
Pratham singhal
Class : Xth ‘D’
Page : 3
30Java Programs
Program 1:
import java.util.*;
class table
int x,i,p;
x=sc.nextInt();
for(i=1;i<=10;i++)
p=x*i;
System.out.println(x+"x"+i+"="+p);
Output :
Enter number to print the table of a number
Page : 4
10
10x1=10
10x2=20
10x3=30
10x4=40
10x5=50
10x6=60
10x7=70
10x8=80
10x9=90
10x10=100
Program 2:
class loop3
int i,j;
for(i=1;i<=5;i++)
for(j=5;j>=i;j--)
System.out.print(j);
Page : 5
System.out.println();
}}
Output :
54321
5432
543
54
Program 3 :
class overload
if(i>j)
else
}
Page : 6
public void compare(char a,char b)
if((int)a>(int)b)
else
if(s.length()>str.length())
else
{
Page : 7
overload ob = new overload();
ob.compare(1,2);
ob.compare('A','B');
ob.compare("red","amisha");
}}
Output:
2 is greater than 1
Program 4:
import java.util.*;
class factorial
int x,f=1;
System.out.println("Enter a number");
x=sc.nextInt();
while(x>0)
f=f*x;
x--;
Page : 8
}
Output :
Enter a number
Factorial is :120
Program 5:
class loop
int i,j,sp=1;
for(i=1;i<=5;i++)
for(j=sp;j>=1;j-=2)
System.out.print(j);
System.out.println();
sp+=2;
Page : 9
}
Output:
1
31
531
7531
97531
Program 6:
class pattern
int i,j;
for(i=1;i<=n;i++)
for(j=1;j<=2;j++)
System.out.print(ch);
System.out.println();
Page : 10
public void polygon(int x,int y)
int i,j;
for(i=1;i<=2;i++)
for(j=1;j<=5;j++)
System.out.print("@");
System.out.println();
int i,j;
for(i=1;i<=3;i++)
for(j=1;j<=i;j++)
System.out.print("*");
System.out.println();
}
Page : 11
public static void main(String args[])
ob.polygon(2,'O');
ob.polygon(2,5);
ob.polygon();
Output:
OO
OO
@@@@@
@@@@@
**
***
Program 7:
import java.util.*;
class student
Page : 12
public double m1,m2,m3,maximum;
nm=name;
age=ag;
m1=ma1;
m2=ma2;
m3=ma3;
average=(m1+m2+m3)/3;
maximum = m1;
maximum = m2;
else
maximum = m3;
Page : 13
}
ob.compute();
ob.display();
Output :
Name = Pratham
Age = 15
Average = 85.0
Program 8:
class loop1
int i,j;
for(i=1;i<=8;i++)
for(j=1;j<=i;j++)
System.out.print(j);
System.out.println( );
Output :
1
12
123
1234
Page : 15
12345
123456
1234567
12345678
Program 9 :
class loop2
int i,j,k,sp=1;
for(i=9;i>=1;i--)
for(k=1;k<=sp;k++)
System.out.print(" ");
for(j=1;j<=i;j++)
System.out.print('#');
System.out.println( );
sp++;
}
Page : 16
}
Output:
#########
########
#######
######
#####
####
###
##
Program 10 :
import java.util.*;
class calls
int code,call;
String nm;
double bill;
code = sc.nextInt();
Page : 17
System.out.println("Enter Calls Made");
call=sc.nextInt();
nm=sc.next();
if(call<=150)
bill=500;
else if(call<=200)
bill=500+(call-150)*0.80;
else if(call<=300)
bill=500+50*0.80+(call-200)*1;
else
bill=500+50*0.80+100*1+(call-300)*1.20;
Output :
Page : 18
Enter Customer Code
2347
200
Pratham
Bill = 540.0
Program 11 :
import java.util.*;
class palindrome
int x,i,d,rev=0;
System.out.println("Enter number");
x=sc.nextInt();
i=x;
while(x>0)
d=x%10;
rev=rev*10+d;
x=x/10;
}
Page : 19
if(i==rev)
else
Output :
Enter number
121
Program 12:
class greatest
if(x>y)
return x;
Page : 20
else
return y;
int i=ob.big(3,4);
Output :
Greatest number = 4
Program 13:
import java.util.*;
class bedroom
public int l;
public int b;
public int h;
Page : 21
public void inputdata()
System.out.println("Enter Length");
l=sc.nextInt();
System.out.println("Enter breadth");
b=sc.nextInt();
System.out.println("Enter height");
h=sc.nextInt();
area=2*(l*b+b*h+h*l);
volume=l*b*h;
ob.inputdata();
ob.calculate();
ob.output();
Output :
Enter Length
12
Enter breadth
Enter height
Area = 216.0
volume = 144.0
Program 14:
import java.util.*;
class temp
int i;
Page : 23
Scanner sc = new Scanner(System.in);
for(i=0;i<f.length;i++)
f[i]=sc.nextDouble();
System.out.println("Temperature in Celcius");
for(i=0;i<f.length;i++)
c[i]=(f[i]-32)*5/9;
System.out.println(c[i]);
Output :
Enter temperature in Fahrenheit
237.5
330.0
560.0
123.0
347.9
Page : 24
Temperature in Celsius
114.16666666666667
165.55555555555554
293.3333333333333
50.55555555555556
175.5
Program 15:
import java.util.*;
class while1
int i,f=1;
i=sc.nextInt();
while(i>0)
f=f*i;
i--;
}
Page : 25
Output :
Enter Number to Print its Factorial
Factorial = 120
Program 16:
class Armstrong
int i,s=0,d,x;
for(i=1;i<=500;i++)
s=0;
x=i;
while(x>0)
d=x%10;
s=s+(d*d*d);
x=x/10;
if(s==i)
Page : 26
System.out.println(i);
Output:
1
153
370
371
407
Program 17:
import java.util.*;
class case_q
char ch;
System.out.println("Enter character");
ch=sc.next().charAt(0);
if(Character.isUpperCase(ch))
Page : 27
System.out.println("Character is in Uppercase");
else if(Character.isLowerCase(ch))
System.out.println("Character is in Lowercase");
else if(Character.isDigit(ch))
System.out.println("Character is Digit");
else
Output :
Enter character
Character is in Uppercase
Program 18 :
class armweak
Page : 28
public int Armstrong(int i)
int y,d,c=0,x;
double s=0;
x=i;
y=i;
while(i>0)
d=i%10;
c++;
i=i/10;
while(y>0)
d=y%10;
s=s+Math.pow(d,c);
y=y/10;
if(x==s)
return 1;
else
{
Page : 29
return 0;
int z=ob.Armstrong(407);
if(z==1)
else
Output :
Number is a Armstrong number
Program 19 :
import java.util.*;
class bubble
Page : 30
public static void main(String args[])
int i,j,temp;
System.out.println("Enter Numbers");
for(i=0;i<num.length;i++)
num[i]=sc.nextInt();
for(i=0;i<num.length;i++)
for(j=0;j<num.length-i-1;j++)
if(num[j]>num[j+1])
temp=num[j];
num[j]=num[j+1];
num[j+1]=temp;
for(i=0;i<num.length;i++)
Page : 31
{
System.out.println(num[i]);
Output :
Enter Numbers
7
Page : 32
8
Program 20 :
import java.util.*;
int c=0;
System.out.println("Enter a String");
String st=sc.nextLine();
char ch=sc.next().charAt(0);
for(int i=0;i<st.length();i++)
char x=st.charAt(i);
if(x==ch)
c++;
}
Page : 33
}
Output :
Enter a String
The frequency of E is 3
Program 21 :
import java.util.*;
String w="";
System.out.println("Enter a String");
String st=sc.nextLine();
for(int i=0;i<st.length();i++)
char x=st.charAt(i);
if(x!='A' && x!='E' && x!='I' && x!='O' && x!='U' && x!='a' && x!='e'
&& x!='i' &&x!='o' && x!='u')
w=w+x;
Page : 34
}
System.out.println(w);
Output :
Enter a String
COMPUTER APPLICATIONS
CMPTR PPLCTNS
Program 22 :
import java.util.*;
int c=0;
System.out.println("enter a string");
String st=sc.nextLine();
for(int i=0;i<st.length();i++)
char x=st.charAt(i);
if(x!=' '&& x!='A' && x!='E' && x!='I' && x!='O' && x!='U' && x!='a'
&& x!='e' &&x!='i' && x!='o' && x!='u')
Page : 35
c++;
Output :
enter a string
Program 23 :
import java.util.*;
System.out.println("Enter a String");
String st=sc.nextLine();
st=st.trim();
st=' '+st;
for(int i=0;i<st.length();i++)
char x=st.charAt(i);
Page : 36
if(x==' ')
System.out.print(st.charAt(i+1)+" ");
Output :
Enter a String
L K A
Program 24 :
import java.util.*;
int c=0;
String w="";
System.out.println("enter a string");
String st=sc.nextLine();
st=st.toUpperCase();
for(int i=0;i<=st.length()-1;i++)
Page : 37
char x=st.charAt(i);
if(x=='A'||x=='E'||x=='I'||x=='O'||x=='U')
x='*';
w=w+x;
System.out.println(w);
Output :
enter a string
Program 25 :
import java.util.*;
String w="";
System.out.println("enter a string");
Page : 38
String st=sc.nextLine();
st=st.trim();
st=" "+st;
for(int i=0;i<st.length();i++)
char x= st.charAt(i);
if(x==' ')
w=w+st.charAt(i+1);
System.out.println(w);
Output :
enter a string
VIRUS
Program 26 :
import java.util.*;
char x;
Page : 39
String s1="",s2="",rev="";
System.out.println("\f");
System.out.println("enter a string");
String st=sc.nextLine();
st= st.toUpperCase();
st=st.trim();
st=st+" ";
for(int i=0;i<st.length();i++)
x=st.charAt(i);
if(x!=' ')
s1=s1+x;
s2=x+s2;
else
if(s1.equals(s2))
System.out.println(s1);
s1="";
s2="";
}
Page : 40
}
Output :
enter a string
MOM
DAD
Program 27 :
import java.util.*;
String w="",s1="";
System.out.println("enter a String:");
st=st.trim()
st=" "+st;
for(int i= st.length()-1;i>=0;i—
x=st.charAt(i);
Page : 41
if(x!=' ')
w=x+w;
else
s1=s1+w+" ";
w="";
System.out.println(s1);
Output :
enter a String:
COMPUTER IS FUN
FUN IS COMPUTER
Program 28 :
import java.util.*;
class primesum
int x,i,d,c=0,s=0;
Page : 42
System.out.println("Enter number");
x=sc.nextInt();
while(x>0)
d=x%10;
c=0;
for(i=2;i<=d/2;i--)
if(d%i==0)
c++;
break;
if(c==0)
s=s+d;
x=x/10;
Output :
Page : 43
Enter number
100
Sum = 1
Program 29 :
class astric
int i,j,x,y;
for(i=1;i<=5;i++)
for(j=1;j<=i;j++)
System.out.print("*");
System.out.println(" ");
for(x=4;x>=1;x--)
for(y=1;y<=x;y++)
System.out.print("*");
System.out.println(" ");
Page : 44
}
Output :
*
**
***
****
*****
****
***
**
Program 30 :
class sign
int sign=-1,x,i,s=0;
for(i=1;i<=10;i++)
x=i*sign*-1;
sign=sign*-1;
Page : 45
System.out.print(x+",");
s=s+x;
Output :
1,-2,3,-4,5,-6,7,-8,9,-10,Sum = -5
I Pratham Singhal here by declare that i have successfully completed my project by the
help of books and some websites : i.e.;
1) Microsoft word
Page : 46
Page : 47