Utkarma Verma - Computer Science Project
Utkarma Verma - Computer Science Project
o Name - Utkarsh
Verma
o Class/Section - XI-A
o Topic of Project -
Computer Science
o Teacher’s Signature-
ACKNOWLEDGEMENT
I would like to express my special thanks of
gratitude to my teacher Mr. Sarfaraz Sir as well
as our senior principal Mrs. Jyoti Ma’am and
junior principal Mrs. Shivani Ma’am, who gave me
the golden opportunity to do this wonderful project
on the topic Computer Science , which also helped
me in doing a lot of Research and I came to know
about so many new things I am really thankful to
them.
Secondly I would also like to thank my parents and
friends who helped me a lot in finalizing this
project within the limited time frame.
Program 1
A class ArrayMax contains a square matrix which finds the largest
element in each row.
Member functions/methods:
void large( ) : finds and displays the largest element in each row
class ArrayMax
{
m = mm ;
for( int i = 0 ; i < m ; i++ )// outer loop for taking input
arr[i][j] = sc.nextInt();
void large()// function that finds and displays each row's largest element
int lgst = 0 ;
{
if( lgst < arr[i][j] )
lgst = arr[i][j] ;
System.out.println();
System.out.println();
System.out.println();
a.display();
a.large();
j Int
Algorithm
Input taken from user, stored in a double dimensional array by using a
for loop with one nested loop. nested fills rows, outer changes rows.
Separate function.
Main function acts as a menu and calls functions to complete the task
and acts as a menu by calling various methods.
Program 2
Design a class WordWise to separate words from a sentence and find
the frequency of the
Member functions/methods:
parameterized string w
import java.util.StringTokenizer ;
class WordWise
str = sc.nextLine();
str = str.trim() ;
int freq_vowel( String w )// function that takes parameter string( assumed
to be a word ) and returns frequency of vowels in it
int a = w.length() ;
w = w.toUpperCase() ;
int b = 0 ;
b++;
i=a;
return b ;
void arrange()
{
StringTokenizer d = new StringTokenizer(str);
int a = str.length();
int b = 0 ;
int c = d.countTokens() ;
if( b == -1 )
str2 = str3 ;
else
str2 = str3.substring(0,b);
if( b!= -1 )
str3 = (str3.substring(b)).trim() ;
}
public static void main()
a.readSent();
a.arrange();
Algorithm
Input (a sentence) is taken from the user and stored in a variable of type
string
The main function simply call the other functions to finish the task
Program 3
Design a class PrimePalinGen to generate prime palindrome numbers. [
A number is said
[ Prime number: A number having only two factors i.e. 1 and itself ]
Methods/Member functions:
returns 0
otherwise returns 0
class PrimePalinGen
int start = 0 ;
int end = 0 ;
start = a ;
end = b ;
if( i%j == 0 )
return 0 ;
return 1 ;
int isPalin(int i )
int a = 0 ;
int temp = i ;
while ( temp != 0 )
a = temp%10 + a*10 ;
temp = temp/10 ;
if( i == a )
return 1 ;
else
return 0 ;
void generate()
System.out.println( " Prime palindrome numbers within " + start + " and "
+ end + " are : " );
System.out.println( i );
}
Variable Type Description
end
Algorithm
A range of numbers ( start and end number ) are taken from the user as
input
Methods/Member functions:
int sum_pow(int i): returns the sum of each digit raised to the power of
the length of the number using recursive technique eg., 34 will return 32
+ 42 (as the length of the number is 2)
class ArmNum
{
int n ;// declares member methods for storing a number and it's length
int l ;
n = nn ;
while( nn != 0 )
l++ ;
nn = nn/10 ;
int sum = 0 ;
int temp = i ;
temp = temp/10 ;
return sum ;
}
void isArmstrong()
if( n == sum_pow(n) )
else
Algorithm
First input is taken from the user for the number to be checked
The final sum is compared with the original number . if they are equal , a
message is displayed telling the user that the number is an armstrong
number . else the message says it is not an Armstrong number
Program 4
A class Rearrange has been defined to modify a word by bringing all the
vowels in the word at the beginning followed by the consonants
Member functions/methods:
void display(): displays the original word along with the rearranged word
Specify the class Rearrange, giving the details of the constructor(), void
readword(), void freq _vow_con(), void arrange() and void display().
Define the main() function to create an object and call the functions
accordingly to enable the task.
import java.util.Scanner ;
class arrange
{
String wrd ;
StringBuffer newwrd ;
arrange( )
wrd = "" ;
wrd = sc.next() ;
wrd = wrd.toUpperCase() ;
newwrd.setLength( wrd.length() ) ;
int vow = 0 ;
int con = 0 ;
{
if( wrd.charAt(i) == 'A' || wrd.charAt(i) == 'E' || wrd.charAt(i) == 'I' ||
wrd.charAt(i) == 'O' || wrd.charAt(i) == 'U' )
vow ++ ;
else
con ++ ;
int ind = 0 ;
ind ++ ;
{
if ( wrd.charAt( i ) == 'A' || wrd.charAt( i ) == 'E' || wrd.charAt( i ) == 'I' ||
wrd.charAt( i ) == 'O' || wrd.charAt( i ) == 'U' )
{}
else
ind ++ ;
System.out.println( " Original word is " + wrd + " \n Rearranged word is "
+ newwrd ) ;
a.readword() ;
a.freq_vow_con() ;
a.arrange() ;
a.display() ;
}
Variable Type Description
Algorithm
Rearrange
The program takes input from the user in the form of a word using a
separate function.
Then the program generates a new word that has the vowels of the
entered word in the beginning of the word by using two for loops. The
first loop checks the letters of the word and on detecting a vowel it is
placed in the beginning of a new word. The second loop does the same
but searches for consonants and places them in string after the vowels.
V = 22/7 × R2 × H
class ShapesVolume {
return V;
double V = 22.0 / 7 * R * R * H ;
return V;
double V = L * B * H;
return V;
}
Algorithm
The program overloads a function volume that finds the volume of a
regular 3d shape assuming the shape based to actual parameters
The program takes basic data about a shape such as its length, radius
etc. and uses mathematical formula to calculate and assign a variable
the volume of the shape and returns said variable
Program 6
Design a class Railway Ticket with following description:
int total amt : To store the amount to be paid after updating the original
amount
Member methods
void accept ( ) — To take input for name, coach, mobile number and
amount
First_ AC 700
Second_AC 500
Sleeper None
import java.io.*;
import java.util.Scanner;
class RailwayTicket {
long mobno;
name = sc.next( );
System.out.print("Enter Mobile Number:");
mobno = sc.nextLong( );
coach = sc.next( );
amt = sc.nextInt( );
void update() {
if (coach.equals("FirstAC"))
else
if (coach.equals("SecondAC"))
else
if (coach.equals("ThirdAC"))
else
void display() {
t.accept();
t.update();
t.display();
Algorithm
The program takes input in form of coach, mobile number of customer
passenger’s name and basic amount of the ticket by involving functions
of scanner class in a separate function.
Then it updates the total amount of the ticket using a function that
determines the final price of the ticket based on the railway company’s
policy using an if else construct .
The program then uses a function that displays the passenger’s info .
Program 7
Write a program to accept name and total marks of N number of
students in two single subscript array name[] and total marks[ ].
import java.io.*;
class NameMarks {
int N = sc.nextInt( );
double sum = 0;
name[i] = sc.next( );
System.out.print("Enter Marks:");
total marks[i] = sc.nextInt();
System.out.println( "The average of the total marks of " +N+ " number of
students: " +average);
}
Variable Type Description
Algorithm
The program first takes input in the form of the number of students and
names of students alongside the marks secured by them. The input is
stored in arrays which are of the size of the number of students. Input is
taken by using a for loop and the sum (for calculating average) is
calculated alongside taking input.
Using a for loop all the student’s deviation from the average is calculated
and immediately displayed and stored .
Program 8
Design a class Perfect to check if a given number is a perfect number or
not. [A number is said to be perfect if sum of the factors of the number
excluding itself is equal to the original number]
Methods/Member functions:
void check(): checks whether the given number is perfect by invoking the
function sum_of_factors() and displays the result with an appropriate
message
import java.io.*;
import java.util.Scanner;
class Perfect{
private int f;
this.num = num;
f = 1;
if(i==f){
return 0;
else if(i%f==0)
else{
f++;
return sumofFactors(i);
if(num==sumofFactors(num))
else
int n = sc.nextInt();
obj.check();
Algorithm
The program checks for a perfect number by calculating the sum of
factors and comparing it with the initial number using a recursive method
done by a separate function.
Another method is used to invoke the first function and compare the
returned value with the first value.
The main method acts as a menu and calls the second function to do the
task .
Program 9
A class Capital has been defined to check whether a sentence has
words beginning with a capital letter or not.
Member functions/methods:
boolean isCap(String w): checks and returns true if the word begins with
a capital letter, otherwise returns false
void display(): displays the sentence along with the frequency of the
words beginning with a capital letter
Specify the class Capital, giving the details of the constructor( ), void
input( ), boolean isCap(String) and void display( ). Define the main( )
function to create an object and call the functions accordingly to enable
the task.
import java.io.*;
import java.util. Scanner;
import java.util.StringTokenizer;
public Capital() {
freq = 0;
sent = sc.nextLine();
boolean isCap(String w) {
char ch = w.charAt(0);
return true;
return false;
if(isCap(word))
freq++;
obj.input();
obj.display();
First input is taken from the user in the form of a sentence using the
scanner method. separate function.
A separate function is used that uses the second function and calculates
the frequency of capital starting words and displays said frequency .
Program 10
A class Merger concatenates two positive integers that are greater than
0 and produces a newly merged integer.
Member functions:
mergNum
void show(): to display the original numbers and the merged number with
appropriate messages
Specify the class Merger giving the details of the constructor, void
readNum(), void joinNum() and void show(). Define the main() function to
create an object and call the functions accordingly to enable the task.
import java.util. Scanner;
class Merger
long magNum;
public Merger()
n1=1;
n2=1;
magNum=11;
n1=(int)Math.abs(sc.nextLong());
n2=(int)Math.abs(sc.nextLong());
if(n1==0)
n1=1;
if(n2==0)
n2=1;
}
public void joinNum()
magNum=Long.parseLong(merged);
obj.readNum();
obj.joinNum();
obj.show();
}
Variable Type Description
n2 long
num2
Algorithm
The program first takes input from the user in the form of two integer
numbers which are immediately stored in the form of their absolute
values. Any value equal to 0 is immediately changed to 1.
Then two string variables are declared and initialized with the value of
one of the parsed integers using the Long.toString() function. the two
strings are then contacted to form a merged integer which is parsed and
stored in a variable of type long.
The two numbers along with the merged number are then displayed.
Program 11
A class SeriesSum is designed to calculate the sum of the following
series:
Sum=x2(1)!+x4(3)!+x6(5)!+…xn(n−1)!
Member functions:
double find fact(int m): to return the factorial of m using the recursive
technique.
double find power(int x, int y): to return x raised to the power of y using
the recursive technique.
(a) Specify the class SeriesSum, giving details of the constructor(int, int),
double find fact(int),
double find power(int, int), void calculate() and void display(). Define the
main() function to create an object and call the functions accordingly to
enable the task. [8]
import java.util.Scanner;
class SeriesSum
int x, n;
double sum;
x=xx;
n=nn;
sum=0.0;
double findfact(int a)
void calculate()
{
for(int i=2;i<=n;i+=2)
void display()
System.out.println("sum="+ sum);
System.out.println( " Please enter the constant then the number of terms
" );
obj.calculate();
obj.display();
Algorithm
The program takes input from the user in form of a constant and the total
number of terms in the series and the input is taken first.
Then using a for loop the sum of the series is calculated. A function is
used to find the power to which the constant is to be raised and another
function the factorial of the divisor is calculated.
The number ‘N’ is palindrome if the original number and its reverse are
the same.
Methods/Member functions:
int reverse(int y): reverses the parameterized argument ‘y’ and stores it
in revenue using a recursive technique
void check(): checks whether the number is a Palindrome by invoking
the function reverse() and display the result with an appropriate
message
Specify the class Palin giving the details of the constructor (), void
accept(), int reverse(int) and void check(). Define the main() function to
create an object and call the functions accordingly to enable the task.
import java.io.*;
class Palin {
int revnum;
Palin() {
num = 0;
revnum = 0;
String a = y. readLine();
num = Integer.parseInt(a);
int reverse(int i) {
if( i%j == 0 )
return 0 ;
return 1 ;
int a = 0 ;
int temp = i ;
while ( temp != 0 )
a = temp%10 + a*10 ;
temp = temp/10 ;
if( i == a )
else
p.accept();
p.check( num );
}
Algorithm
The program takes a number as input.
The program uses a for loop to check weather a number is palindrome
or not
Program 13
A class Adder has been defined to add any two accepted times.
Member functions/methods:
void addtime (Adder X, Adder Y): adds the time of the two parameterized
objects X and Y and stores the sum in the current calling object
Specify the class Adder giving details of the constructor( ), void read
time( ), void addtime(Adder, Adder) and void disptime(). Define the
main() function to create objects and call the functions accordingly to
enable the task.
Answer:
import java.util.Scanner;
class Adder {
int a[];
Adder() {
a = new int[2];
System.out.println("Enter hour:");
a[0] = sc.nextInt();
a[1] = sc.nextInt();
a[1] = minSum%60;
}
void disptime() {
obj1.read time();
obj2.read time();
sumObj.addtime(obj1, obj2);
sumObj.disptime();
hour2
min1
min2
Algorithm
Adder
The program takes input in the form of time, hours and minutes.
The sum is calculated using a formula related to the 60 min hour format.
The main class creates two objects of Adder type and uses the add time
function of the object it’s part of that takes objects of type Adder as
actual parameters .
Program 14
It contains a square matrix which finds the largest element in each row.
Member functions/methods:
void large( ) : finds and displays the largest element in each row
class ArrayMax
m = mm ;
for( int i = 0 ; i < m ; i++ )// outer loop for taking input
arr[i][j] = sc.nextInt();
void large()// function that finds and displays each row's largest element
int lgst = 0 ;
lgst = arr[i][j] ;
System.out.println();
System.out.println();
System.out.println();
a.readarray();
a.display();
a.large();
j Int
Main function acts as a menu and calls functions to complete the task
and acts as a menu by calling various methods.
Program 15
Design a class WordWise to separate words from a sentence and find
the frequency of the
Member functions/methods:
parameterized string w
import java.util.StringTokenizer ;
class WordWise
str = sc.nextLine();
str = str.trim() ;
int freq_vowel( String w )// function that takes parameter string( assumed
to be a word ) and returns frequency of vowels in it
int a = w.length() ;
w = w.toUpperCase() ;
int b = 0 ;
b++;
i=a;
return b ;
void arrange()
{
int a = str.length();
int b = 0 ;
int c = d.countTokens() ;
if( b == -1 )
str2 = str3 ;
else
str2 = str3.substring(0,b);
if( b!= -1 )
str3 = (str3.substring(b)).trim() ;
}
}
a.readSent();
a.arrange();
Algorithm
Input (a sentence) is taken from the user and stored in a variable of type
string
The main function simply call the other functions to finish the task
Program 16
Design a class PrimePalinGen to generate prime palindrome numbers. [
A number is said
[ Prime number: A number having only two factors i.e. 1 and itself ]
Methods/Member functions:
returns 0
otherwise returns 0
class PrimePalinGen
int start = 0 ;
int end = 0 ;
start = a ;
end = b ;
if( i%j == 0 )
return 0 ;
return 1 ;
int isPalin(int i )
int a = 0 ;
int temp = i ;
while ( temp != 0 )
a = temp%10 + a*10 ;
temp = temp/10 ;
if( i == a )
return 1 ;
else
return 0 ;
void generate()
System.out.println( " Prime palindrome numbers within " + start + " and "
+ end + " are : " );
System.out.println( i );
}
Variable Type Description
end
Algorithm
A range of numbers ( start and end number ) are taken from the user as
input
Program 17
Design a class ArmNum to check if a given number is an Armstrong
number or not. [A number is said to be Armstrong if sum of its digits
raised to the power of length of the number is equal to the number
Methods/Member functions:
int sum_pow(int i): returns the sum of each digit raised to the power of
the length of the number using recursive technique eg., 34 will return 32
+ 42 (as the length of the number is 2)
class ArmNum
int n ;// declares member methods for storing a number and it's length
int l ;
Arm Numb( int nn )// parameterised constructor
n = nn ;
while( nn != 0 )
l++ ;
nn = nn/10 ;
int sum = 0 ;
int temp = i ;
temp = temp/10 ;
return sum ;
void isArmstrong()
if( n == sum_pow(n) )
System.out.println( n + " is an armstrong number " ) ;
else
Algorithm
First input is taken from the user for the number to be checked
The final sum is compared with the original number . if they are equal , a
message is displayed telling the user that the number is an armstrong
number . else the message says it is not an Armstrong number
Program 18
A class Rearrange has been defined to modify a word by bringing all the
vowels in the word at the beginning followed by the consonants
Member functions/methods:
void display(): displays the original word along with the rearranged word
Specify the class Rearrange, giving the details of the constructor(), void
readword(), void freq _vow_con(), void arrange() and void display().
Define the main() function to create an object and call the functions
accordingly to enable the task.
import java.util.Scanner ;
class arrange
{
String wrd ;
StringBuffer newwrd ;
arrange( )
wrd = "" ;
wrd = sc.next() ;
wrd = wrd.toUpperCase() ;
newwrd.setLength( wrd.length() ) ;
int vow = 0 ;
int con = 0 ;
else
con ++ ;
int ind = 0 ;
ind ++ ;
{}
else
ind ++ ;
System.out.println( " Original word is " + wrd + " \n Rearranged word is "
+ newwrd ) ;
a.readword() ;
a.freq_vow_con() ;
a.arrange() ;
a.display() ;
}
Variable Type Description
Algorithm
Rearrange
The program takes input from the user in the form of a word using a
separate function.
Then the program generates a new word that has the vowels of the
entered word in the beginning of the word by using two for loops. The
first loop checks the letters of the word and on detecting a vowel it is
placed in the beginning of a new word. The second loop does the same
but searches for consonants and places them in string after the vowels.
V = 22/7 × R2 × H
class ShapesVolume {
return V;
double V = 22.0 / 7 * R * R * H ;
return V;
return V;
Algorithm
The program overloads a function volume that finds the volume of a
regular 3d shape assuming the shape based to actual parameters
The program takes basic data about a shape such as its length, radius
etc. and uses mathematical formula to calculate and assign a variable
the volume of the shape and returns said variable
Program 20
Design a class Railway Ticket with following description:
int total amt : To store the amount to be paid after updating the original
amount
Member methods
void accept ( ) — To take input for name, coach, mobile number and
amount
First_ AC 700
Second_AC 500
Sleeper None
import java.io.*;
import java.util.Scanner;
class RailwayTicket {
long mobno;
mobno = sc.nextLong( );
coach = sc.next( );
amt = sc.nextInt( );
void update() {
if (coach.equals("FirstAC"))
else
if (coach.equals("SecondAC"))
else
if (coach.equals("ThirdAC"))
else
void display() {
t.accept();
t.update();
t.display();
Then it updates the total amount of the ticket using a function that
determines the final price of the ticket based on the railway company’s
policy using an if else construct .
The program then uses a function that displays the passenger’s info .
Program 21
Write a program to accept name and total marks of N number of
students in two single subscript array name[] and total marks[ ].
import java.io.*;
class NameMarks {
int N = sc.nextInt( );
double sum = 0;
for (int i = 0; i < N; i++) {
name[i] = sc.next( );
System.out.print("Enter Marks:");
System.out.println( "The average of the total marks of " +N+ " number of
students: " +average);
}
Variable Type Description
Algorithm
The program first takes input in the form of the number of students and
names of students alongside the marks secured by them. The input is
stored in arrays which are of the size of the number of students. Input is
taken by using a for loop and the sum (for calculating average) is
calculated alongside taking input.
Using a for loop all the student’s deviation from the average is calculated
and immediately displayed and stored .
Program 22
Design a class Perfect to check if a given number is a perfect number or
not. [A number is said to be perfect if sum of the factors of the number
excluding itself is equal to the original number]
Methods/Member functions:
void check(): checks whether the given number is perfect by invoking the
function sum_of_factors() and displays the result with an appropriate
message
import java.io.*;
import java.util.Scanner;
class Perfect{
private int f;
this.num = num;
f = 1;
if(i==f){
return 0;
else if(i%f==0)
else{
f++;
return sumofFactors(i);
if(num==sumofFactors(num))
else
int n = sc.nextInt();
obj.check();
Algorithm
The program checks for a perfect number by calculating the sum of
factors and comparing it with the initial number using a recursive method
done by a separate function.
Another method is used to invoke the first function and compare the
returned value with the first value.
The main method acts as a menu and calls the second function to do the
task .
Program 23
A class Capital has been defined to check whether a sentence has
words beginning with a capital letter or not.
Member functions/methods:
boolean isCap(String w): checks and returns true if the word begins with
a capital letter, otherwise returns false
void display(): displays the sentence along with the frequency of the
words beginning with a capital letter
Specify the class Capital, giving the details of the constructor( ), void
input( ), boolean isCap(String) and void display( ). Define the main( )
function to create an object and call the functions accordingly to enable
the task.
import java.io.*;
import java.util. Scanner;
import java.util.StringTokenizer;
public Capital() {
freq = 0;
sent = sc.nextLine();
boolean isCap(String w) {
char ch = w.charAt(0);
return true;
return false;
if(isCap(word))
freq++;
obj.input();
obj.display();
First input is taken from the user in the form of a sentence using the
scanner method. separate function.
A separate function is used that uses the second function and calculates
the frequency of capital starting words and displays said frequency .
Program 24
A class Merger concatenates two positive integers that are greater than
0 and produces a newly merged integer.
Member functions:
mergNum
void show(): to display the original numbers and the merged number with
appropriate messages
Specify the class Merger giving the details of the constructor, void
readNum(), void joinNum() and void show(). Define the main() function to
create an object and call the functions accordingly to enable the task.
import java.util. Scanner;
class Merger
long magNum;
public Merger()
n1=1;
n2=1;
magNum=11;
n1=(int)Math.abs(sc.nextLong());
n2=(int)Math.abs(sc.nextLong());
if(n1==0)
n1=1;
if(n2==0)
n2=1;
}
public void joinNum()
magNum=Long.parseLong(merged);
obj.readNum();
obj.joinNum();
obj.show();
}
Variable Type Description
n2 long
num2
Algorithm
The program first takes input from the user in the form of two integer
numbers which are immediately stored in the form of their absolute
values. Any value equal to 0 is immediately changed to 1.
Then two string variables are declared and initialized with the value of
one of the parsed integers using the Long.toString() function. the two
strings are then contacted to form a merged integer which is parsed and
stored in a variable of type long.
The two numbers along with the merged number are then displayed.
Program 25
A class SeriesSum is designed to calculate the sum of the following
series:
Sum=x2(1)!+x4(3)!+x6(5)!+…xn(n−1)!
Member functions:
double find fact(int m): to return the factorial of m using the recursive
technique.
double find power(int x, int y): to return x raised to the power of y using
the recursive technique.
(a) Specify the class SeriesSum, giving details of the constructor(int, int),
double find fact(int),
double find power(int, int), void calculate() and void display(). Define the
main() function to create an object and call the functions accordingly to
enable the task. [8]
import java.util.Scanner;
class SeriesSum
int x, n;
double sum;
x=xx;
n=nn;
sum=0.0;
double findfact(int a)
void calculate()
{
for(int i=2;i<=n;i+=2)
void display()
System.out.println("sum="+ sum);
System.out.println( " Please enter the constant then the number of terms
" );
obj.calculate();
obj.display();
Algorithm
The program takes input from the user in form of a constant and the total
number of terms in the series and the input is taken first.
Then using a for loop the sum of the series is calculated. A function is
used to find the power to which the constant is to be raised and another
function the factorial of the divisor is calculated.
The number ‘N’ is palindrome if the original number and its reverse are
the same.
Methods/Member functions:
int reverse(int y): reverses the parameterized argument ‘y’ and stores it
in revenue using a recursive technique
void check(): checks whether the number is a Palindrome by invoking
the function reverse() and display the result with an appropriate
message
Specify the class Palin giving the details of the constructor (), void
accept(), int reverse(int) and void check(). Define the main() function to
create an object and call the functions accordingly to enable the task.
import java.io.*;
class Palin {
int revnum;
Palin() {
num = 0;
revnum = 0;
String a = y. readLine();
num = Integer.parseInt(a);
int reverse(int i) {
if( i%j == 0 )
return 0 ;
return 1 ;
int a = 0 ;
int temp = i ;
while ( temp != 0 )
a = temp%10 + a*10 ;
temp = temp/10 ;
if( i == a )
else
p.accept();
p.check( num );
}
Algorithm
The program takes a number as input.
Member functions/methods:
void addtime (Adder X, Adder Y): adds the time of the two parameterized
objects X and Y and stores the sum in the current calling object
Specify the class Adder giving details of the constructor( ), void read
time( ), void addtime(Adder, Adder) and void disptime(). Define the
main() function to create objects and call the functions accordingly to
enable the task.
import java.util.Scanner;
class Adder {
int a[];
Adder() {
a = new int[2];
System.out.println("Enter hour:");
a[0] = sc.nextInt();
a[1] = sc.nextInt();
a[1] = minSum%60;
void disptime() {
obj1.read time();
obj2.read time();
sumObj.addtime(obj1, obj2);
sumObj.disptime();
hour2
min1
min2
Algorithm
Adder
The program takes input in the form of time, hours and minutes.
The sum is calculated using a formula related to the 60 min hour format.
The main class creates two objects of Adder type and uses the add time
function of the object it’s part of that takes objects of type Adder as
actual parameters .
BIBLIOGRAPHY
o https://www.google.com/