Computer Project Class 10 Icse Programming Divine Mercy
Computer Project Class 10 Icse Programming Divine Mercy
CLASS-X SECTION-A
REGISTRATION NUMBER-161
TOPIC-Java Programming and BlueJ
SUBJECT-Computer Applications
Unique ID- 7526233
SCHOOL-Divine Mercy School
SESSION-2021-2022
Acknowledgement
I would like to express my special thanks of gratitude to
my Computer Applications teacher Miss Anita Ma’am
for her able guidance and support for completing my
project. I would also like to thank our honorable
Principal Mr. Rajib Chakraborty for giving us this
golden opportunity to do this project on the topic ‘’Java
Programming and BlueJ”, which helped me a lot in
doing a lot of research. I am really thankful to them.
Secondly, I would also like to thank my parents and
friends, who helped me in finalizing this project within
the limited time frame.
CONTENT
Serial Number Subtopic Page Number
01 WAP to show discount 05-06
for Laptops
02 WAP to see whether 07-08
the number is
palindrome or special
number
03 WAP to initialize ‘The 09-10
Seven Wonders of the
World’ along with their
locations in two
different arrays
04 WAP with class 11-12
name FruitJuice
05 WAP Designing a 13-14
class to overload a
function series( )
06 WAP designing a class 15-16
to overload a function
polygon()
07 WAP to assign a full 17-19
path and file name
08 WAP to assign a full 20-21
path and file name
09 WAP in Java to accept a 21-22
String in upper case and
replace all the vowels
present in the String with
Asterisk (*) sign
10 WAP to input integer 23-24
elements into an array of
size 20
11 WAP to generate a 24-27
triangle or an
inverted triangle
based upon User’s
choice
12 WAP for a Unique 27-28
string
13 WAP to generate a 29-30
Floyd and ISCE
Pattern
14 WAP for Binary 31-32
search
15 WAP to calculate 32-34
the ACSII
difference
16 WAP for the 35-36
Piglatin number
17 WAP for Perfect 37-38
square
18 WAP to calculate 39-40
the Marks of 40
students
19 WAP to see 41-43
whether the
number is Prime or
Automorphic
number
20 WAP to calculate 44-45
the Fibonacci
series or sum of
digits
1.\\WAP to show the special discount on the purchase of Laptops
import java.util.Scanner;
Variable Description:-
Variable Description:-
if (i == locations.length)
System.out.println("Sorry Not Found!");
}
}
Variable Description:-
Output:-
4. //WAP defining a class named FruitJuice with the given instructions:
Member Purpose
Methods
FruitJuice() constructor to initialize integer data members to 0 and string data
members to ""
void input() to input and store the product code, flavour, pack type, pack size
and product price
void discount() to reduce the product price by 10
void display() to display the product code, flavour, pack type, pack size and
product price
import java.util.Scanner;
public FruitJuice()
{
product_code = 0;
flavour = "";
pack_type = "";
pack_size = 0;
product_price = 0;
}
1. double series(double n) with one double argument and returns the sum of the
series.
sum = (1/1) + (1/2) + (1/3) + ………. + (1/n)
2. double series(double a, double n) with two double arguments and returns the
sum of the series.sum = (1/a2) + (4/a5) + (7/a8) + (10/a11) + ………. to n terms
public class Series
{
double series(double n) {
double sum = 0;
for (int i = 1; i <= n; i++)
{
double term = 1.0 / i;
sum += term;
}
return sum;
}
Output:-
6. //WAP to design a class to overload a function polygon() as follows:
1 void polygon(int n, char ch) — with one integer and one character
type argument to draw a filled square of side n using the character stored
in ch.
2 void polygon(int x, int y) — with two integer arguments that draws a
filled rectangle of length x and breadth y, using the symbol '@'.
3 void polygon() — with no argument that draws a filled triangle..
public class Polygon
{
public void polygon(int n, char ch) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
System.out.print(ch);
}
System.out.println();
}
}
Variable Description:-
Member Methods:
import java.util.Scanner;
public Calculate(int n) {
num = n;
f = 0;
rev = 0;
}
f = 1;
if (num == 0 || num == 1)
f = 0;
else
for (int i = 2; i <= num / 2; i++) {
if (num % i == 0) {
f = 0;
break;
}
}
return f;
}
int t = num;
while (t != 0) {
int digit = t % 10;
rev = rev * 10 + digit;
t /= 10;
}
return rev;
}
Output:-
Q8. //WAP to assign a full path and file name as given below. Using library functions,
extract and output the file path, file name and file extension separately as shown.
Input C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg
import java.util.*;
public class path_8
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String str,name="",exten="",path="";
int a=0,b=0;
System.out.println("Enter the String");
str = sc.nextLine();
a = str.lastIndexOf('\\');
b = str.lastIndexOf('.');
path = str.substring(0,a+1);
name = str.substring(a+1,b);
exten = str.substring(b+1);
System.out.println("Path : "+path);
System.out.println("File name: "+name);
System.out.println("File Extension : "+exten);
}
}
Output:-
Variable Description:-
9. //WAP in Java to accept a String in upper case and replace all the vowels
present in the String with Asterisk (*) sign.
Sample Input: "TATA STEEL IS IN JAMSHEDPUR"
Sample output: T*T* ST**L *S *N J*MSH*DP*R
import java.util.Scanner;
System.out.println(newStr);
}
}
Variable Description:-
Variable Description:-
Output:-
Q11. //WAP to generate a triangle or an inverted triangle based upon User’s choice.
Example 1:
Input: Type 1 for a triangle and Type 2 for an inverted triangle
Enter your choice 1 Enter a word : BLUEJ
Sample Output: if choice is 1 Output will be
B
LL
UUU
EEEE
JJJJJ
if choice is 2 Output will be
BLUEJ
BLUE
BLU
BL
B
import java.util.Scanner;
public class PatternedTraingle
{
public static void choosePattern()
{
Scanner sc = new Scanner(System.in);
System.out.println("Type 1 for triangle type 1");
System.out.println("Type 2 for triangle type 2");
System.out.print("Enter your choice: ");
int ch = sc.nextInt();
switch(ch)
{
case 1:
System.out.print("Enter your word: ");
String word1 = sc.next();
int n1=word1.length();
int k=0;
for(int i=0;i<=n1-1;i++)
{
for(int j=0;j<=k;j++)
{
System.out.print(word1.charAt(i));
}
System.out.println();
k++;
}
break;
case 2:
System.out.print("Enter your word: ");
String word = sc.next();
int n=word.length();
for(int i=n;i>=0;i--)
{
System.out.println(word.substring(0,i));
}
break;
default:
System.out.println("Wrong Choice");
break;
}
}
}
Output:-
Variable Description:-
Variable Name Data Type Function
ch Integer To accept choice from the
user
n1 Integer To find the length of the
word
Word1 Integer To accept the word
k Integer To calculate the number
of rows
i Integer To enter into loop
j Integer To calculate the number
of rows
word String To accept the word from
the user
n Integer To find the length of the
word
12. //WAP where a string is said to be ‘Unique’ if none of the letters present
in the string are repeated. Write a program to accept a string and check
whether the string is Unique or not. The program displays a message
accordingly.
Sample Input: COMPUTER
Sample Output: Unique String
import java.util.Scanner;
char ch = str.charAt(i);
if (!isUnique)
break;
}
if (isUnique)
System.out.println("Unique String");
else
System.out.println("Not Unique String");
}
}
Variable Description:-
Output:-
13. //WAP using the switch statement, write a menu driven program for
the following:
(a) To print the Floyd’s triangle:
(b) To display the following pattern:
I
IC
ICS
ICSE
For an incorrect option, an appropriate error message should be displayed.
import java.util.Scanner;
switch (ch) {
case 1:
int a = 1;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(a++ + "\t");
}
System.out.println();
}
break;
case 2:
String s = "ICSE";
for (int i = 0; i < s.length(); i++) {
for (int j = 0; j <= i; j++) {
System.out.print(s.charAt(j) + " ");
}
System.out.println();
}
break;
default:
System.out.println("Incorrect Choice");
}
}
}
Output:-
Variable Description:-
if (idx == -1)
System.out.println("Record does not exist");
else
System.out.println("Record exists");
}
}
Variable Description:-
Output:-
15. //WAP to input two characters from the keyboard. Find the difference
(d) between their ASCII codes. Display the following messages: If d=0 : both
the characters are same. If d<0 : first character is smaller. If d>0 : second
character is smaller.
Sample Input : D P
Sample Output : d= (68-80) = -12 First character is smaller
import java.util.Scanner;
public class PerfectSquare_17
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter first number: ");
int a = in.nextInt();
System.out.print("Enter second number: ");
int b = in.nextInt();
if (a < 0 || b < 0)
{
System.out.println("Square root of a negative number can't be determined");
}
else
{
double sqrtA = Math.sqrt(a);
double sqrtB = Math.sqrt(b);
double isAPerfectSq = sqrtA - Math.floor(sqrtA);
double isBPerfectSq = sqrtB - Math.floor(sqrtB);
if (isAPerfectSq == 0 &&isBPerfectSq == 0)
{
System.out.println("They are perfect square numbers.");
}
else if (isAPerfectSq == 0)
{
System.out.println(a + " is a perfect square number.");
System.out.println(b + " is not a perfect square number.");
}
else if (isBPerfectSq == 0)
{
System.out.println(a + " is not a perfect square number.");
System.out.println(b + " is a perfect square number.");
}
else
{
System.out.println("Both are not perfect square numbers.");
}
}
}
}
Output:-
Variable Description:-
16. //WAP that encodes a word into Pig latin. To translate word into Pig latin 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);
}
}
Variable Description:-
17. //WAP to input two unequal positive numbers and check whether they
are perfect square numbers or not. If the user enters a negative number
then the program displays the message 'Square root of a negative number
can't be determined'.
Sample Input: 81, 100
Sample Output: They are perfect square numbers.
Sample Input: 225, 99
Sample Output: 225 is a perfect square number. 99 is not a perfect square
number.
import java.util.Scanner;
if (a < 0 || b < 0) {
System.out.println("Square root of a negative number can't be
determined");
}
else {
double sqrtA = Math.sqrt(a);
double sqrtB = Math.sqrt(b);
double isAPerfectSq = sqrtA - Math.floor(sqrtA);
double isBPerfectSq = sqrtB - Math.floor(sqrtB);
Variable Description:-
Variable name Variable type Description
a int To accept a number from
the user
b int To accept another number
from the user
sqrtA double To find the square root of a
18. //WAP to input marks in English, Maths and Science of 40 students who
have passed ICSE Examination 2014. Now, perform the following tasks:
(a) Number of students, who have secured 95% or more in all the subjects.
(b) Number of students, who have secured 90% or more in English, Maths
and Science.
import java.util.Scanner;
19. Write a menu driven program to accept a number from the user and
check whether it is a Prime number or an Automorphic number.
(a) Prime number: (A number is said to be prime, if it is only divisible by 1
and itself) Example: 3,5,7,11
(b) Automorphic number: (Automorphic number is the number which is
contained in the last digit(s) of its square.) Example: 25 is an Automorphic
number as its square is 625 and 25 is present as the last two digits.
import java.util.Scanner;
public class PrimeOrAuto_19
{
public static void main(String args[])
{
int i,ch,num,C=0;
Scanner sc=new Scanner(System.in);
System.out.println("***************MENU***************");
System.out.println("Type 1 to check if the number is a Prime Number");
System.out.println("Type 2 to check if the number is an Automorphic
Number");
ch = sc.nextInt();
switch(ch)
{
case 1:
System.out.println("Enter the number: ");
num=sc.nextInt();
for(i=1;i<=num;i++)
{
if(num%i==0)
{
C++;
}
}
if(C==2)
{
System.out.println("It is a Prime Number");
}
else
{
System.out.println("It is not a Prime Number");
}
break;
case 2:
System.out.println("Enter the number");
int number = sc.nextInt();
int A=0, square = number*number;
int dot = number;
while(dot>0)
{
A++;
dot=dot/10;
}
int LSQ = (int) (square%(Math.pow(10,A)));
if(number == LSQ)
{
System.out.println("It is an Automorphic Number");
}
else
{
System.out.println("It is not an Automorphic Number");
}
break;
default:
System.out.println("Wrong Choice");
}
}
}
Output:-
Variable Description:-
(b) find the sum of the digits of an integer that is input by the user.
Sample Input: 15390
Sample Output: Sum of the digits = 18
For an incorrect choice, an appropriate error message should be displayed
import java.util.Scanner;
switch (ch) {
case 1:
int a = 0, b = 1;
System.out.print(a + " " + b);
case 2:
System.out.print("Enter number: ");
int num = in.nextInt();
int sum = 0;
while (num != 0) {
sum += num % 10;
num /= 10;
}
System.out.println("Sum of Digits " + " = " + sum);
break;
default:
System.out.println("Incorrect choice");
break;
}
}
}
Output:-
Variable Description:-
Variable name Variable type Description
ch int To accept choice from
the user
a int Predefined value for
the Fibonacci series
b int Predefined value for
the Fibonacci series
i int To enter into loop
term int To get the sum of
previous number
num int To accept a number
sum int To find the sum of the
numbers
Chemistry Project
File
Divine Mercy School
Class-10 Section-A
UID-7526233
Session- 2021-2022
Physics Project
File
Divine Mercy School
Class-10 Section-A
UID-7526233
Session- 2021-2022
Mathematics Project
File
Class-10 Section-A
UID-7526233
Session- 2021-2022