Computer Project
Computer Project
PROJECT FILE
SUBJECT – Computer Applications
SESSiOn: 2023-2024
Submitted By
NAME: Pragya Pandey
CLASS: X Science
Submitted To
Ms. Anita Chhattani
ACKNOWLEDGEMENT
2. 1-D-Array programs
3. 2-D-Array programs
4. Method Overloading programs
5. Constructor/Encapsulation programs
String programs
Output
Write a program in Java to accept a word a String and
display the new string after removing all the vowels present
in it.
Sample input: Computer Applications
Sample Output: Cmptr pplctns
import java.util.Scanner;
import java.util.Scanner;
import java.util.Scanner;
Write a program in Java to enter a String/Sentence and display the longest word and
the length of the longest word present in the String.
Sample input: “TATA FOOTBALL ACADEMY WiLL pLAY AGAinST MOHAn BAGAn”
Sample Output: The longest word: FOOTBALL: The length of the word: 8
import java.util.Scanner;
word = "";
}
else {
word += ch;
}
}
}
Output
Write a program in Java to enter a sentence. Frame a word by joining all the first
characters of each word of the sentence. Display the word.
import java.util.Scanner;
System.out.println(word);
}
}
Output
Write a program in Java to enter a sentence. Display the words which are only
palindrome.
import java.util.Scanner;
if (ispalin)
System.out.println(word);
word = "";
}
else {
word += ch;
}
}
}
}
Output
Write a program to input a sentence and display the word of the sentence that contains
maximum number of vowels.
import java.util.Scanner;
char ch = Character.toUpperCase(str.charAt(i));
if (ch == 'A' ||
ch == 'E' ||
ch == 'i' ||
ch == 'O' ||
ch == 'U') {
count++;
}
if (isHappy)
System.out.println("A Happy Word");
else
System.out.println("not a Happy Word");
}
}
Output
Write a program to input a sentence. Count and display the frequency of each
letter of the sentence in alphabetical order.
A 2 O 2
C 2 p 3
i 1 R 1
L 2 S 1
M 1 T 2
n 1 U 1
import java.util.Scanner;
System.out.println("Character\tFrequency");
for( (int i = 0; i < freqMap.length; i++) {
if (freqMap[i] > 0) {
System.out.println((char)(i + 65)
+ "\t\t" + freqMap[i]);
}
}
}
}
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;
}
}
Output
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;
Output
Write a program to input a sentence. Convert the sentence into upper case letters. Display the
words along with frequency of the words which have at least a pair of consecutive letters.
import java.util.Scanner;
word = "";
}
else {
word += str.charAt(i);
}
OUTPUT
Sample Input
Enter 20 numbers
12
34
66
78
69
88
59
96
58
48
93
57
63
29
79
68
59
53
48
86
Number of even numbers= 11
Number of odd numbers = 9
Number of multiple of 4= 6
import java.util.*;
int i,j,c1=0,c2=0,c3=0;
System.out.println("Enter 20 numbers");
for(i=0;i<20;i++)
a[i] = in.nextInt();
}
for( i=0;i<20;i++)
if(a[i]%2 == 0)
c1++;
if(a[i]%2 !=0)
c2++;
if(a[i]%4 ==0)
c3++;
}}
OUTPUT
Enter integer numbers=
34
56
78
34
46
86
24
15
47
68
89
46
34
56
68
45
34
23
Menu items
import java.util.*;
int n,s,i,j;
a[i]= in.nextint();
System.out.println(“Menu items”);
n=in.nextint();
switch(n)
case 1:
for(i=0;i<20;i++)
s=0;
for(j=1;j<a[i];j++)
if(a[i]%j==0)
s = s+j;
56
47
56
7
if(s==a[i])
System.out.println(a[i]);
break;
case 2:
for(i=0;i<20;i++)
if(a[i]%7==0||a[i]%10==7)
System.out.println(a[i]);
break;
default:
System.out.println(“invalid choice”);
}}}
2-D ARRAY
pROGRAMS
OUTPUT
Enter the number of rows:
43
45
56
76
78
23
23
34
45
56
76
56
43
23
21
import java.util.*;
int m,n;
m=s.nextInt();
System.out.println("Enter the number of column: \n");
n=s.nextInt();
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
a1[i][j]=s.nextInt();
43 45 56 76
78 23 23 34
45 56 76 7
56 43 23 21
43 78 45 56
45 23 56 43
56 23 76 23
76 34 7 21
for(int i=0;i<m;i++)
for(int j=0;j<n;j++)
System.out.print(a1[i][j]+" ");
System.out.println("");
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
a2[j][i]=a1[i][j];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
System.out.print(a2[i][j]+" ");
}
System.out.println("");
}
OUTPUT
The numbers of the matrix are:
12
23
45
65
43
32
76
65
21
43
56
76
89
29
56
34
12 23 45 65
43 32 76 65
21 43 56 76
89 29 56 34
import java.util.*;
int i,j,d1,rd,k;d1=0;rd=0;
for(i=0;i<4;i++)
for(j=0;j<4;j++)
m[i][j]= in.nextInt();
for(i=0;i<4;i++)
for(j=0;j<4;j++)
System.out.print(m[i][j]+" ");
System.out.println();
for(i=0;i<4;i++)
d1=d1+m[i][i];
k=3;
for(i=0;i<4;i++)
rd=rd+m[i][k];
k=k-1;
}
OUTPUT
Enter numbers of the first matrix
4
3
5
6
7
8
9
2
3
4
5
6
7
8
9
1
Enter the numbers of the second matrix
2
3
4
5
6
7
8
9
9
8
7
6
5
4
3
2
Sum of the array elements is:
6 6 9 11
13 15 17 11
12 12 12 12
12 12 12 3
import java.io.*;
int i,j;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
m[i][j]= Integer.parseInt(in.readLine());
for(i=0;i<4;i++)
for(j=0;j<4;j++)
n[i][j]=Integer.parseInt(in.readLine());
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
p[i][j]=m[i][j]+n[i][j];
System.out.println();
}
OUTPUT
Enter the numbers of the matrix
6
The numbers of the matrix are:
1 2 3 2 4 5 3 5 6
it is a symmetric matrix
import java.util.*;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
m[i][j]=in.nextint();
}
System.out.println(“The numbers of the matrix are:”);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
System.out.print(m[i][j]+ “ “);
System.out.println();
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
if m[i][j]!=m[j][i])
k=1;
if(k==0)
else
}
METHOD
OVERLOADinG
pROGRAMS
OUTPUT
if(ch=='s')
else
if(ch=='p')
else
}
public void num_cal(String str1, String str2)
if(str1.equals(str2))
else
OUTPUT
class Overload
double s, ar;
s= (a+b+c)/2;
ar=Math.sqrt(s*(s-a)*(s-b)*(s-c));
return(ar);
double ar;
ar= 1.0/2.0*height*(a+b);
return(ar);
double ar;
ar= 1.0/2.0*(diagonal1*diagonal2);
return (ar);
OUTPUT
Enter the last limit of the series
34
class Over_loading
int i;
for(i=1;i<=n;i++)
if(i%2==0)
sum=sum-(double)x/i;
else
sum=sum+(double)x/i;
}
System.out.println("sum of first series="+sum);
void sumSeries()
int i,p=1,sum1=0;
for(i=1;i<=20;i++)
p=p*i;
sum1=sum1+p;
}
public static void main(String args[])
int n;
double x;
n=in.nextInt();
x=in.nextDouble();
ob.sumSeries(n,x);
ob.sumSeries();
}
COnSTRUCTOR
pROGRAMS
OUTPUT
Enter employee’s name, Employee number, Basic Salary
"HARI NARAYAN"
9413974799
49999
name="HARI NARAYAN"
Employee number=9413974799
Gross Salary=Rs.72498.55
net Salary=Rs.66498.67
import java.util.*;
String name,empno;
int basic;
double da,hra,pf,gs,net;
na,e = n;
empno=en;
basic=bs;
void compute()
da=basic*30.0/100.0;
hra=basic*15.0/100.0;
pf=basic*12.0/100.0;
gs=basic+da+hra;
net=gs-pf;
void display()
System.out.println(“name=“+name);
System.out.println(“Employee number=“+empno);
System.out.println(“Gross Salary=Rs.”+gs);
System.out.println(“net Salary=Rs.”+net);
}
String nm,enm;
int bsal;
nm=in.nextLine();
Enm=in.next();
Bsal=in.nextint();
ob.compute();
ob.display();
}
OUTPUT
Enter student’s name, Age, Marks in three subjects one by one=
"Riya Agarwal"
16
78
89
97
Age=16years
String name;
int age,m1,m2,m3,max;
double avg;
name = n;
Age = d;
M1= a;
M2=b;
M3=c;
void compute()
Avg=(m1+m2+m3)/3;
Max=m2;
Max=m3;
void display()
{
System.out.println(“name =“+ name);
System.out.println(“Age=“+age+ “years”);
String nm;
int ag,a1,b1,c1;
nm=in.nextLine();
Ag=in.nextLine();
A1=in.nextLine();
B1=in.nextLine();
C1=in.nextLine();
ob.display();