Final Copy Computer Project
Final Copy Computer Project
ᵜASSESSMENT SHEETᵜ
➤NAME:-
➤CLASS:- XII
➤ROLL NO:-
➤SESSION:- 2025-26
□SIGNATURES□
INTERNAL EXAMINER:-_____________________
EXTERNAL EXAMINER:-
PRINCIPAL:- _
2
ACKNOWLEDGEMENT
I would like to express my special
thanks of gratitude to Sir Manager
and Ma’am Principal for giving us
the opportunity to complete this
project.
Name
3
INTRODUCTION
4
⩩INDEX⩩
S. No. Program Page no Signatures
3. PALINDROME 14-18
PROGRAM.
1
12. IDENTITY MATRIX. 58-62
2
⫷Program-1⫸
3
#ALGORITHM#
Step 1: Class fillMatrix created
Step 2: Size of the matrix is entered by the user.
Step 3: Condition is checked for size entered by the user.
Step 4: Characters to be filled in the matrix is entered by the
user.
Step 5: Characters are filled according to the condition
given in the question.
Step 6: Resultant matrix is printed.
4
import
java.util.*;
class FillMatrix
{
5
public static void main (String args [])
{
Scanner sc = new Scanner(System.in);
System.out.print("Matrix size: ");
int n = sc.nextInt();
if(n < 4 || n > 9){
System.out.println("Size out of range!")
return;
}
6
m[i][j] = third;
}
}
m[0][0] = first;
m[n - 1][n - 1] = first;
m[0][n - 1] = first;
m[n - 1][0] = first;
System.out.println("Resultant Matrix:");
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
System.out.print(m[i][j] + "\t");
}
System.out.println();
}
1OUT4UT1
7
::VDT::
VARIABLE DATA-TYPE DESCRIPTION
M char Matrix
8
⫷4ROGRAM-2⫸
Design a class Convert to find the date and the month from a
given day number for a particular year.
Example: If day number is 64 and the year is 2020, then the
corresponding date would be: March 4, 2020 i.e. (31 + 29 + 4
= 64).
#ALGORITHM#
Step1: Class Convert created.
Step 2: Day number and Year will be entered by the user in the
function accept.
Step 3: Day number and year is validated as per the given
conditions.
Step 4: If either the day number or the year is invalid, the
compiler will exit the program.
Step 5: If the day and year is valid, then the day number
will be converted to a date in the function dayToDate.
Step 6: Calculated date will be printed by the function
display. Step 7: End.
9
import java.util.*;
class Convert
{
int n;
int d;
int m;
int y;
public Convert()
{
n = 0;
d = 0;
m = 0;
y = 0;
10
if(d > 366){
int a[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
a[1] = 29;
int sum = 0;
if(d <= 31)
m = 0;
else
11
{
while(d > 0)
d -= a[m];
m++;
if(d <= a[m])
break;
}
12
Convert obj = new Convert();
obj.accept(); obj.dayToDate();
obj.display();
}
⧫OUT4UT⧫
13
VARIABLE DATA TYPE DESCRIPTION
y int Year
m int position
a int Array
14
⫷4ROGRAM-3⫸
Write a program to accept a sentence which may be terminated
by either ‘.’, ‘?’ or ‘!’ only. The words are to be separated by a
single blank space and are in uppercase.
HELPLEH.
15
sentence.
#ALGORITHM#
Step1: Class Convert created.
Step 2: Accepting sentence
Step 3:Checking for the validity of accepted sentence
Step 4: Convert non-palindrome sentences into palindrome
words by concatenating the word by its reverse (excluding
the last character).
Step 5: Printing result
Step 6: End.
import java.util.*;
import java.util.StringTokenizer;
class Palindrome{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
System.out.print("Sentence: ");
String s = sc.nextLine().trim().toUpperCase(); char
ch = s.charAt(s.length() - 1);
if(ch != '.' && ch != '?' && ch != '!')
{ System.out.println("INVALID INPUT");
16
return;
}
}
System.out.println(s);
System.out.println(p);
}
}
public static String generate(String w){
17
String r = new String();
for(int i = w.length() - 2; i >= 0; i--) r
+= w.charAt(i);
while(w.length() > 1 && w.charAt(w.length() - 1) ==
w.charAt(w.length() - 2))
w = w.substring(0, w.length() - 1);
return w + r;
}
}
?OUTPUT?
18
::VDT::
VARIABLE DATATYPE DESCRIPTION
19
⫷4ROGRAM-4⫸
A Goldbach number is a positive even integer that can be
expressed as the sum of two odd primes.
Example:
6=3+3
10 = 3 + 7
10 = 5 + 5
20
#ALGORITHM#
Step1: Class Convert created.
Step 2: Entering the number.
Step 3: Finding Prime Number of Number
Step 4: Adding Prime Number
Step 5: Checking
Step 6: Printing Result
Step 7: End.
import java.util.*;
class Goldbach
{
21
return;
}
}
System.out.println("Prime pairs are:"); while(p
< n){
q = n - p;
}
}
public static boolean isPrime(int n){ int
f = 0;
for(int i = 1; i <= n; i++){
if(n % i == 0) f+
+;
}
if(f == 2) return
22
true;
return false;
}
}
⧫OUT4UT⧫
23
::VDT::
VARIABLE DATATYPE DESCRIPTION
n int Factor
q int Factor
24
⫷4ROGRAM-5⫸
Write a program to declare a square matrix a[][] of order M × M
where ‘M’ is the number of rows and the number of columns,
such that M must be greater than 2 and less than
10. Accept the value of M as user input. Display an appropriate
message for an invalid input. Allow the user to input integers
into this matrix. Perform the following tasks:
#ALGORITHM#
25
import java.util.*;
class Rotate{
public static void main(String args[])
{
Scanner sc= new Scanner (System.in);
System.out.print("M = ");
int m = sc.nextInt();
if(m < 3 || m > 9){
System.out.println("SIZE OUT OF RANGE");
return;
}
}
System.out.println("ORIGINAL MATRIX");
for(int i = 0; i < m; i++){
for(int j = 0; j < m; j++)
{ System.out.print(a[i][j] + "\t");
}
26
System.out.println();
}
int r[][] = new int[m][m];
int row = 0; int col = m -
1; for(int i = 0; i < m; i++){
row = 0;
col--;
}
System.out.println("MATRIX AFTER ROTATION"); for(int i
= 0; i < m; i++){
for(int j = 0; j < m; j++)
{ System.out.print(r[i][j] + "\t");
}
System.out.println();
int last = m - 1;
int sum = a[0][0] + a[0][last] + a[last][0] + a[last][last];
System.out.println("Sum of the corner elements = " +
sum);
}
}
27
⧫OUTpUT⧫
28
::VDT::
29
⫷4ROGRAM-C⫸
import java.util.*;
class MatrixSort{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("M = ");
int m = sc.nextInt();
if(m < 4 || m > 9){
System.out.println("THE MATRIX SIZE IS OUT OF
RANGE.");
return;
}
int a[][] = new int[m][m];
System.out.println("Enter positive integers:");
for(int i = 0; i < m; i++)
for(int j = 0; j < m; j++)
a[i][j] = Math.abs(sc.nextInt());
System.out.println("ORIGINAL MATRIX");
for(int i = 0; i < m; i++){
for(int j = 0; j < m; j++)
{ System.out.print(a[i][j] + "\t");
31
}
System.out.println();
}
int b[] = new int[(m - 2) * (m - 2)];
int k = 0;
for(int i = 1; i < m - 1; i++){
}
for(int i = 0; i < b.length; i++){
for(int j = 0; j < b.length - 1 - i; j++)
{ if(b[j] > b[j + 1]){
int temp = b[j];
b[j] = b[j + 1];
b[j + 1] = temp;
}
}
}
k = 0;
for(int i = 1; i < m - 1; i++)
{ for(int j = 1; j < m - 1; j+
+){
32
a[i][j] = b[k++];
33
}
}
System.out.println("REARRANGED MATRIX"); for(int i
= 0; i < m; i++){
for(int j = 0; j < m; j++)
{ System.out.print(a[i][j] + "\t");
}
System.out.println();
}
int sum = 0;
System.out.println("DIAGONAL ELEMENTS");
for(int i = 0; i < m; i++){
for(int j = 0; j < m; j++){
if(i == j || i + j == m - 1)
{ System.out.print(a[i][j] + "\
t"); sum += a[i][j];
}
else
System.out.print("\t");
}
System.out.println();
}
System.out.println("SUM OF THE DIAGONAL ELEMENTS
= " + sum);
34
}
}
⧫OUT4UT⧫
35
::VDT::
36
⫷4ROGRAM-7⫸
A Circular Queue is a linear data structure which works on the
principle of FIFO, enabling the user to enter data from the rear
end and remove data from the front end with the rear end
connected to the front end to form a circular pattern.
#ALGORITHM#
Step1: Creating the class
Step 2:Enables the user to enter data
Step 3:Remove data from the front end
Step 4: Connecting to the front end to form a circular pattern
Step 5: Checking
Step 6: Printing
Step 7: End.
import java.util.*;
class CirQueue
{
int cq[];
int cap;
37
int front;
int rear;
public CirQueue(int max)
{ cap = max;
front = 0;
rear = 0;
cq = new int[cap];
}
public void push(int n){ if((rear +
1) % cap != front){
rear = (rear + 1) % cap;
cq[rear] = n;
}
else
System.out.println("QUEUE IS FULL");
}
public int pop()
{ if(front != rear){
int n = cq[front];
else
38
return -9999;
}
public void show()
{ if(front != rear){
for(int i = front; i <= rear; i = (i + 1) % cap)
System.out.print(cq[i] + "\t");
System.out.println();
}
else
System.out.println("QUEUE IS EMPTY");
}
}
⧫OUTPUT⧫
39
::VDT::
Variable Data type Description
40
⫷4ROGRAM-8⫸
An Achilles Number is a number that is powerful but not a perfect
power.
A Powerful Number is a positive integer N, such that for every
prime factor p of N, p2 is also a factor.
A Perfect Power is a positive integer N such that it can be
expressed as ab, where a and b are natural numbers > 1.
72, 108, 200, 288 are some of the first few Achilles Numbers.
#ALGORITHM#
Step1: creating the class
Step 2:entering the number
Step 3: finding the prime number
Step 4: checking
Step 5: printing result
Step 6: end
41
import java.util.*;
class Power
{
public static boolean isPerfectPower(int num){
}
return false;
}
public static void main(String args[])
{ Scanner sc=new Scanner(System.in);
System.out.print("Enter the number: ");
int num = sc.nextInt();
boolean status = true; if(!
isPerfectPower(num)){
int n = num;
int pf = 2;
42
while(n != 1){
if(n % pf == 0){
int s = pf * pf;
if(num % s != 0){
status = false;
break;
}
n /= pf;
}
else
pf++;
}
}
else
status = false;
if(status)
System.out.println(num + " is an Achilles Number.");
else
System.out.println(num + " is not an Achilles
Number.");
}
}
43
⧫OUT4UT⧫
::VDT::
Variable Data type Description
i int row
j int colomb
pf int To store 2
44
⫷4ROGRAM-9⫸
A Prime-Adam integer is a positive integer (without leading
zeroes) which is a prime as well as an Adam number.
Prime number: A number which has only two factors, i.e. 1 and
the number itself. Example: 2, 3, 5, 7, etc.
Adam number: The square of a number and the square of its
reverse are reverse to each other. Example: If n = 13 and reverse
of ‘n’ is 31, then, 132 = 169, and 312 = 961 which is reverse of 169.
Thus, 13 is an Adam number.
Accept two positive integers m and n, where m is less than n as
user input. Display all Prime-Adam integers that are in the range
between m and n (both inclusive) and output them along with the
frequency, in the format given below:
Test your program with the following data and some random
data:
Example 1:
INPUT:
m=5
n = 100
OUTPUT:
The Prime-Adam integers are:
11, 13, 31
Frequency of Prime-Adam integers is:3
45
#ALGORITHM#
Step1: creating the class
Step 2: entering the number
Step 3: checking whether the entered number is prime
number or not
Step 4: squaring the number
Step 5: reversing the
number Step 6: checking
Step 7: printing the result
step8: end
import java.util.*;
class PrimeAdam
{
public static void main(String args[])
int count = 0;
if(count == 0) System.out.println("NIL");
else
47
System.out.println();
if(n % i == 0)
f++;
}
return f == 2;
48
}
⧫OUT4UT⧫
::VDT::
Variable Data type Description
49
⫷4ROGRAM-10⫸
Prime Palindrome
#ALGORITHM#
Step1: creating the class
Step 2:entering the number
Step 3: finding the prime number
Step 4: reversing the number
Step 5: checking
Step 6: printing the result
Step 7: End.
import java.util.*;
50
class PrimePalindrome
System.out.print("m = ");
int m = sc.nextInt();
System.out.print("n = ");
int n = sc.nextInt();
{ System.out.println("OUT OF RANGE.");
return;
int count = 0;
51
for(int i = m; i <= n; i++)
if(count == 0)
System.out.print(i);
else
}
System.out.println();
System.out.println("FREQUENCY OF PRIME PALINDROME
INTEGERS: " + count);
52
rev = 0;
return n == rev;
f = 0;
{ if(n % i == 0)
f++;
if(f > 2)
return false;
}
return f == 2;
53
⧫OUT4UT⧫
::VDT::
54
COUNT INT ADDING
⫷4rOGraM-11⫸
Reverse Matrix Elements
Example:
becomes
27 173 5
#ALGORITHM#
55
Step 5: end.
import java.util.*;
class MatRev{
private int arr[][];
private int m;
private int n;
public MatRev(int mm, int nn){
m = mm;
n = nn;
}
}
public int reverse(int x){
int rev = 0;
56
for(int i = x; i != 0; i /= 10)
rev = rev * 10 + i % 10;
return rev;
}
public void revMat(MatRev p){
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++)
{
this.arr[i][j] = reverse(p.arr[i][j]);
}
}
}
public void show(){ for(int
i = 0; i < m; i++){
for(int j = 0; j < n; j++)
{ System.out.print(arr[i][j] + "\t");
}
System.out.println();
}
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
57
System.out.print("Enter number of rows: ");
int x = sc.nextInt();
System.out.print("Enter number of columns: ");
int y = sc.nextInt();
MatRev obj1 = new MatRev(x, y);
MatRev obj2 = new MatRev(x, y);
obj1.fillArray(); obj2.revMat(obj1);
System.out.println("Original Matrix");
obj1.show();
⧫OUT4UT⧫
58
::VDT::
m int To store
positive no.
J INT COLOMB
59
⫷4ROGRAM-12⫸
Program to check whether the matrix entered is
Identity matrix or not.
#ALGORITHM#
Step1: creating the class
Step 2:entering the size of the matrix
Step 3:Checks whether given matrix is a square matrix or not
Step 4:Checks if diagonal elements are equal to 1 and rest of
elements are 0
Step 5: checking
Step 6: printing the result
Step 7: End.
import java.util.*;
public class IdentityMatrix
{
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in); int
row, cols;
boolean flag = true;
//Initialize matrix a
int a[][] =new int [row][cols];
System.out.println("Enter the elements of matrix");
for(int i=0; i<row; i++)
{
for(int j=0;j<cols;j++)
{
a[i][j]= sc.nextInt();
}
}
//Checks whether given matrix is a square matrix or not if(row
!= cols)
{
61
for(int j = 0; j < cols; j++){
if(i == j && a[i][j] != 1){
flag = false;
break;
}
}
}
if(flag)
System.out.println("Given matrix is an identity
matrix");
else
System.out.println("Given matrix is not an identity
matrix");
}
}
}
62
⧫OUT4UT⧫
63
::VDT::
VARIABLE DATA-TYPE DESCRIPTION
M char Matrix
6
2
⫷4ROGRAM-13⫸
A happy number is a number in which eventual sum of the square
the digit is equal to one.
Example:- 100= 1^2 + 0^2+0^2=1. Hence, number is a happy
number
Design a class Happy to check whether a number is happy or not.
Class Name : Happy
Data members \instant variables :-
n : Stores the number
Member functions :-
Happy( ) : Constructor to assign 0 to n.
void getnum(int nn) : to assign a parameter value to n=nn.
void int sum_sq_digits(int x) : to find the sum of square digits using
recursion.
void ishappy() : check whether a number is happy or not by calling.
sum_sq_digits method
Also, define a main() function to create an object and call the
methods to check whether a number is happy number or not.
#ALGORITHM#
STEP 1- Class Happy created.
STEP 2- Number entered by the user.
STEP 3-Sum of the digits of the number found using recursion
technique.
STEP 4-Condition is checked for the number to be a happy number.
STEP 5-Appropriate message is displayed.
STEP 6-END.
6
2
import java.util.Scanner;
class Happy
{
int n,s,d;
Happy()
{
n=0;
}
void get_num(int nm)
{
n=nm;
}
int sum_sq_digits(int x)
{
if(x>0)
{
d=x%10;
s=s+d*d;
x=x/10;
return sum_sq_digits(x);
}
else
{
return s;
63
}}
void isHappy()
{
int a;
while(n>9)
{
s=0;
n=sum_sq_digits(n);
}
if(n==1)
{
System.out.println("HAPPY NUMBER");
}
else
{
System.out.println("NOT A HAPPY NUMBER");
}}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a
number"); int num=sc.nextInt();
{
Happy ob=new Happy();
ob.get_num(num);
ob.sum_sq_digits(num);
ob.isHappy();
}
64
}
}
⧫OUT4UT⧫
::VDT::
65
⫷4ROGRAM-14⫸
Write a program to accept a matrix from the user and print its
lower and upper triangle .
Example:
Matrix:
0011
0111
0001
0000
Output:
Upper Triangle
0 011
011
00
0
Lower Triangle
1
01
0001
0000
#ALGORITHM#
Import java.util.*;
68
}
// Function to read user input
public static void mainFunction to display upper and lower
triangle
(String[] args) {
Scanner sc=new Scanner(System.in);
int order;
System.out.println("Enter the order of the matrix");
try{
order =sc.nextInt();
}
catch(Exception e)
{
System.out.println("An error occurred");
return;
}
int[][] matrix = new int[order][order];
System.out.println("Enter matrix elements");
int i,j;
for(i=0; i<order; i++)
{ for(j=0; j<order; j++){
try{
matrix[i][j] = sc.nextInt();
}
catch(Exception e){
System.out.println("An error
occurred"); return;
}
69
}
}
System.out.println("Tha matrix is");
for(i=0; i<order; i++){
for(j=0; j<order; j++)
{ System.out.print(matrix[i][j] + "\t");
}
System.out.println();
}
System.out.println("The upper and lower triangle is");
displayUpperAndLowerTriangle(matrix);
}
}
70
⧫OUT4UT⧫
71
::VDT::
M char Matrix
72
⫷4ROGRAM-15⫸
Write a program to accept a sentence which may be terminated by
either’.’, ‘?’or’!’ only. The words may be separated by more than
one blank space and are in UPPER CASE.
(a) Find the number of words beginning and ending with a vowel.
(b) Place the words which begin and end with a vowel at the
beginning, followed by the remaining words as they occur in
the sentence.
Test your program with the sample data and some random data:
Example 1
73
#ALGORITHM#
Step1: creating the class
Step 2:entering the word
Step 3:Finding the number of words beginning and ending
with a vowel.
Step 4: Place the words which begin and end with a vowel at
the beginning, followed by the remaining words as they occur
in the sentence.
Step 5: checking
Step 6: printing
Step 7: End.
import java.util.*;
class Vowel
{
boolean isVowel(String w) // Function to check if a word begins
and ends with a vowel or not
{
int l = w.length();
char ch1 = w.charAt(0); // Storing the first character
char ch2 = w.charAt(l-1); // Storing the last character
if((ch1=='A' || ch1=='E' || ch1=='I' || ch1=='O' || ch1=='U') &&
74
(ch2=='A' || ch2=='E' || ch2=='I' || ch2=='O' || ch2=='U'))
{
return true;
}
else
{
return false;
}
}
if(ob.isVowel(w))
{
}
}
76
⧫OUT4UT⧫
::VDT::
VARIABLE DATA-TYPE DESCRIPTION
77
⫷4ROGRAM-1C⫸
Write a program to accept a sentence which may be terminated by
either ‘.’ ‘?’ or ‘!’ only. Any other character may be ignored. The
words may be separated by more than one blank space and are in
UPPER CASE.
(a) Accept the sentence and reduce all the extra blank
space between two words to
a single blank space.
(b) Accept a word from the user which is part of the
sentence along with its position number and delete the word
and display the sentence.
Test your program with the sample data and some random data:
Example 1
WORD TO BE DELETED: IS
WORD POSITION IN THE SENTENCE: 6
78
#ALGORITHM#
Step1: creating th class
Step 2:accepting he sentence
Step 3:reducing all the extra blank space between two words
to a single blank space.
Step 4: Accept a word from the user which is part of the
sentence along with its position number and delete the word
and display the sentence.
Step 5: checking
Step 6: printing
Step 7: End.
import java.util.*;
class RemoveWord
{
public static void main (String args[])
{
i int looping
81
⫷4ROGRAM-17⫸
Write a program to input a word from the user and remove the
duplicate characters present in it.
Example:
INPUT – abcabcabc
OUTPUT – abc
#ALGORITHM#
Step1: creating the class
Step 2:entering te woard
Step 3:checking the duplicate words
Step 4: removing the duplicate words
Step 5: checking
Step 6: printing
Step 7: End.
82
import java.util.*;
class RemoveDupChar
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter any word :
"); String s = sc.next();
int l = s.length();
char ch;
String ans="";
::VDT::
84
ANS STRING SPACE
⫷4ROGRAM-18⫸
The result of a quiz competition is to be prepared as follows:
The quiz has five questions with four multiple choices (A, B, C, D),
with each question carrying 1 mark for the correct answer. Design
a program to accept the number of participants N such that N
must be greater than 3 and less than 11, Accept a word from the
user which is part of the sentence along with its position number
and delete the word and display the sentence.
. Create a double dimensional array of size (Nx5) to store the
answers of each participant row-wise.
#ALGORITHM#
Step1: crating the class
85
Step 2: accept the number of participants N such that N must
be greater than 3 and less than 11
Step 3:Accept a word from the user which is part of the
sentence along with its position number and delete the word
and display the sentence.
Step 4: Create a double dimensional array of size (Nx5) to
store the answers of each participant row-wise.
Step 5: Calculate the marks for each participant by matching
the correct
Step 6: Display the scores for each participant and also the
participant(s) having the highest score.
Step 7: End.
import java.util.*;
class QuizResult
{
char A[][],K[];
int S[],n;
void input()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of participants : ");
n = sc.nextInt();
if(n<4 || n>10)
{
86
System.out.println("INPUT SIZE OUT OF RANGE");
System.exit(0);
}
A = new char[n][5]; // Array to store the answers of every
participants
K = new char[5]; // Array to store answer key
S = new int[n]; // Array to store score of every participant
System.out.println("\n* Enter answer of each participant
row-wise in a single line *\n");
for(int i = 0; i<n; i++)
{
System.out.print("Participant "+(i+1)+" : ");
for(int j=0; j<5; j++)
{
A[i][j] = sc.next().charAt(0);
}
}
System.out.print("\nEnter Answer Key : ");
for(int i = 0; i<5; i++)
{
K[i] = sc.next().charAt(0);
}
}
void printScore()
{
int max = 0; System.out.println("\
nSCORES : "); for(int i = 0; i<n; i++)
{
System.out.println("\tParticipant "+(i+1)+" = "+S[i]);
if(S[i]>max)
{
max = S[i]; // Storing the Highest Score
}
}
System.out.println();
88
System.out.println("\tHighest Scorers : ");
for(int i = 0; i<n; i++) // Printing all those participant number
who got highest score
{
if(S[i] == max)
{
System.out.println("\t\t\tParticipant "+(i+1));
}
}
}
89
OUT4UT
::VDT::
VARIABLE DATA TYPE DESCRIPTION
90
I INT ROW
J INT COLOMB
⫷4ROGRAM-19⫸
N INT TO STORE NUMBER
Test your program with the sample data and some random data:
Example 1
INPUT : N = 726
OUTPUT :
48 x 15 = 720
6x1=6
Remaining boxes = 0
Total number of boxes = 726
Total number of cartons = 16
91
#ALGORITHM#
Step1: create the class
Step 2: accept the number of boxes to be packed (N) by the
user (maximum up to 1000 boxes)
Step 3:display the break-up of the cartons used in descending
order of capacity
Step 4: checking
Step 5: printing
Step 6: end
class BoxPacking
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
94
}
}
}
⧫OUT4UT⧫
::VDT::
95
⫷4ROGRAM-20⫸
Write a Program in Java to input a number and check whether it is
an Evil Number or not.
import java.util.*;
class EvilNumber
{
String toBinary(int n) // Function to convert a number to Binary
{
int r;
String s=""; //variable for storing the result
while(n>0)
{
r=n%2; //finding remainder by dividing the number by 2
s=dig[r]+s; //adding the remainder to the result and
reversing at the same time
n=n/2;
}
return s;
}
if(x%2==0)
System.out.println(n+" is an Evil Number.");
else
98
System.out.println(n+" is Not an Evil Number.");
}
}
⧫OUT4UT⧫
::VDT::
VARIABLE DATA TYPE DESCRIPTION
S STRING STORING THE RESULT
N INT FINDING REMAINDER
C INT COUNTING
99
CH CHARACTER CHECKING
BIBLIOGRA4HY
cLass 12 cOMpUTEr bOOK.
GOOGLE.
WIKIpEDIa.
10
0