Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

COMPUTER

APPLICATIO
N PROJECT
ISCE (2021 -
22)
NAME: TOSHIT AGARWAL
CLASS: 10 SEC: D
ROLL NUMBER: 40

1
ACKNOWLEDGEMENT
This Project would not have been possible without the guidance and
the help of several individuals who in one way or another contributed
and extended their valuable assistance in the preparation and
completion of this study.
First and foremost, I express utmost gratitude to our computer
Teacher, Sir Bhadra whose inputs and encouragement has been my
inspiration as I hurdle over the obstacles in the completion of this
project work.
I thank all the members of the family who always had a kind concern
and consideration regarding all my project and academic
requirements.
Last but not the least, I thank my classmates for all the cooperation
and resources they extended to me. I specially thank to our Principal
Sir for his selfless interest in my project.

NAME: TOSHIT AGARWAL


CLASS: 10 SEC: D
ROLL NUMBER: 40

2
CONTENTS

SL TOPIC PAGE
NO.
1) PROGRAM 1 4-11
2) PROGRAM 2 12-14
3) PROGRAM 3 15-17
4) PROGRAM 4 18-21
5) PROGRAM 5 22-23
6) BIBLIOGRAPHY 24

3
PROGRAM 1
Define a class Recurring Patterns and define methods in it which will
print the following patterns
a) The method takes an integer argument n and prints the following
pattern, shown for n=4.
a
a a
a a a
a a a a
a a a
a a
a

b) The method takes an integer argument and prints the following


pattern, shown for n=4.
1
123
12321
1234321
12321
121
1
c) The method takes an integer argument and prints the following
pattern, shown for n=4.

abcdcba
abc cba
4
ab ba
a a
ab ba
abc cba
abcdcba

SOLUTION:
import java.util.*;
class Recurring_Patterns
{
void Input1(int n)
{
int i,j,c,k;
c=n-1;
for(i=1;i<=n;i++)
{
for(k=1;k<=c;k++)
System.out.print(" ");
for(j=1;j<=i;j++)
System.out.print("a"+" ");
System.out.println();
c=c-1;

5
}
c=c+2;
for(i=n-1;i>=1;i--)
{
for(k=1;k<=c;k++)
System.out.print(" ");
for(j=1;j<=i;j++)
System.out.print("a"+" ");
System.out.println();
c=c+1;
}
}
void Input2(int n)
{
int i,j,k,c;
c=n-1;
for(i=1;i<=n;i++)
{
for(k=1;k<=c;k++)
System.out.print(" ");
for(j=1;j<=i;j++)
6
System.out.print(j+" ");
for(j=i-1;j>=1;j--)
System.out.print(j+" ");
System.out.println();
c=c-1;
}
c=c+2;
for(i=n-1;i>=1;i--)
{
for(k=1;k<=c;k++)
System.out.print(" ");
for(j=1;j<=i;j++)
System.out.print(j+" ");
for(j=i-1;j>=1;j--)
System.out.print(j+" ");
System.out.println();
c=c+1;
}
}
void Input3(int n)
{
7
int i,j,k,c;
char ch;
c=1;
ch='a';
for(i=1;i<=n;i++)
System.out.print(ch++);
--ch;
for(i=1;i<n;i++)
System.out.print(--ch);
System.out.println();
for(i=n-1;i>=1;i--)
{
ch='a';
for(j=1;j<=i;j++)
System.out.print(ch++);
for(k=1;k<=c;k++)
System.out.print(" ");
for(j=1;j<=i;j++)
System.out.print(--ch);
System.out.println();
c=c+2;
8
}
c=c-4;
for(i=2;i<n;i++)
{
ch='a';
for(j=1;j<=i;j++)
System.out.print(ch++);
for(k=1;k<=c;k++)
System.out.print(" ");
for(j=1;j<=i;j++)
System.out.print(--ch);
System.out.println();
c=c-2;
}
ch='a';
for(i=1;i<=n;i++)
System.out.print(ch++);
--ch;
for(i=1;i<n;i++)
System.out.print(--ch);
}
9
}

OUTPUT:

10
VARIABLE DESCRIPTION:
VARIABLE DATA DESCRIPTION
TYPE
n Int It is the integer argument in the method
i Int For running the loop
j Int For running the loop
k Int For running the loop
c Int Represents the running of loop
ch Char Stores the character needed to be print
in the last method

11
PROGRAM 2
The International Standard Book Number (ISBN) is a unique numeric
book identifier which is printed on every book. The ISBN is based
upon a 10-digit code.
The ISBN is legal if:
1 × digit1 + 2 × digit2 + 3 × digit3 + 4 × digit4 + 5 × digit5 + 6 ×
digit6 + 7 × digit7 + 8 × digit8 + 9 × digit9 + 10 × digit10 is divisible
by 11.
Example: For an ISBN 1401601499 Sum = 1 × 1 + 2 × 4 + 3 × 0 + 4
× 1 + 5 × 6 + 6 × 0 + 7 × 1 + 8 × 4 + 9 × 9 + 10 × 9 = 253 which is
divisible by 11.
Write a program to: Input the ISBN code as a 10-digit integer.
If the ISBN is not a 10-digit integer, output the message "Illegal
ISBN" and terminate the program.
If the number is divisible by 11, output the message "Legal ISBN". If
the sum is not divisible by 11, output the message "Illegal ISBN".

SOLUTION:
import java.util.*;
class ISBN
{
void main()
{
Scanner sc=new Scanner(System.in );
long isbn,i,c=0,s=0;
12
System.out.println("Enter The ISBN Number");
isbn=sc.nextLong();
for(i=isbn;i>0;i/=10)
{
c++;
}
if(c!=10)
{
System.out.println("Illegal ISBN");

}
else
{
for(i=isbn;i>0;i/=10)
{
s=s+(i%10*c--);
}
if(s%11==0)
System.out.println("legal ISBN");
else
System.out.println("Illegal ISBN");
13
}
}
}

OUTPUT:

VARIABLE DATA TYPE DESCRIPTION


isbn long To store the 10 digit number
i long To run the loop of digit extraction
s long To take out the sum to check for
ISBN
c long To count the number of digits

14
PROGRAM 3
Write a program to input 10 integer elements in an array and sort
them in descending order using bubble sort technique.

SOLUTION:
import java.util.*;
class Bubble_Sort
{
void main()
{
int a[]=new int[10];
int i,j,t=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter any 10 numbers");
for(i=0;i<10;i++)
{
a[i]=sc.nextInt();
}
for(i=0;i<9;i++)
{
for(j=0;j<9-i;j++)
{
15
if(a[j]<a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
System.out.println("The Sorted Array In Descending
Order:");
for(i=0;i<10;i++)
{
System.out.print(a[i]+"\t");
}
}
}

16
OUTPUT:

VARIABLE DESCRIPTION:
VARIABLE DATA TYPE DESCRIPTION
a int To store the array elements
i int For running the loop
j int For running the loop
t int For interchanging numbers
according to their decreasing order

17
PROGRAM 4
Using the switch statement, write a menu driven program:
i. To check and display whether a number input by the user is a
composite number or not.
A number is said to be composite, if it has one or more than one
factors excluding 1 and the number itself.
Example: 4, 6, 8, 9...
ii. To find the smallest digit of an integer that is input:
Sample input: 6524
Sample output: Smallest digit is 2.
For an incorrect choice, an appropriate error message should be
displayed.

SOLUTION:
import java.util.*;
class Switch_Case
{
void main()
{
Scanner sc=new Scanner(System.in);
int ch,a,i,c=0,s=9;
System.out.println("Enter your choice:");

18
System.out.println("1 to displaying whether the number
is compostie or not");
System.out.println("2 to finding smallest digit of a
number");
ch=sc.nextInt();
switch(ch)
{
case 1:
System.out.println("Enter the number");
a=sc.nextInt();
for(i=2;i<a;i++)
{
if(a%i==0)
c++;
}
if(c!=0)
System.out.println("YES,IT IS A COMPOSITE
NUMBER");
else
System.out.println("NO,IT IS NOT A COMPOSITE
NUMBER");
break;
19
case 2:
System.out.println("Enter the number");
a=sc.nextInt();
for(i=a;i>0;i/=10)
{
if(i%10<s)
s=i%10;
}
System.out.println("Smallest digit is "+ s);
break;

default:
System.out.println("WRONG CHOICE");

}
}
}

OUTPUT:
20
VARIABLE DESCRIPTION:
VARIABLE DATA TYPE DESCRIPTION
a int Stores the number needed to be
checked if composite or not or
whose smallest digit is to be
found
i int Running the loop
s int Smallest digit storing
c int Stores the number of factors
ch int Stores the choice of the user

21
PROGRAM 5
Write a program to accept a number and check and display whether it
is a Niven number or not.
(Niven number is that number which is divisible by its sum of
digits.).
Example:
Consider the number 126. Sum of its digits is 1 + 2 + 6 = 9 and 126 is
divisible by 9.

SOLUTION:
import java.util.*;
class NIVEN
{
void main()
{
Scanner sc=new Scanner(System.in);
int a,i,s=0;
System.out.println("Entern a Number");
a=sc.nextInt();
for(i=a;i>0;i/=10)
{
s=s+i%10;

22
}
if(a%s==0)
System.out.println("YES,IT IS A NIVEN NUMBER");
else
System.out.println("NO,IT IS NOT A NIVEN
NUMBER");
}
}

OUTPUT:

VARIABLE DESCRIPTION:
VARIABLE DATA TYPE DESCRIPTION
a int Stores the number input by the user
i int For running the loop
s int Counting sum of digits of the number

23
BIBLIOGRAPHY
*I HAVE USED SOME AMOUNT OF HELP FROM MY
BROWSER:
www.google.com

*BOOKS BEEN REFERRED TO:


COMPUTER APPLICATIONS TEXTBOOK FOR CLASS 10
(SCHOOL BOOK)

24

You might also like