First 5
First 5
Variable List
Variable Type Description
Name
N int No. of boxes to be packed
Function Description:
Function Return Argument Argument Description
Name Type name Type
This method calculates the
no. of cartons of each size
packBoxes() void N int needed & calls the method
displayCartonsUsed() to
display the results
Calculates the total no. of
boxes,
calculateCartons() int int, int cartons of certain sizes
cartonsize
needed to pack the boxes.
Prints the no. of cartons of
c48, c24, c12,
displayCartonsUsed() void int, int, int, int, int each size used and the total
c6, boxes
no. of boxes & cartons used.
Main entry point of the
program; calls the methods
main() void - -
to calculate the no. of
cartons used.
Program No.2
Variable List
Variable Type Description
Name
m int Number of rows in the matrix
Function Description:
Function Return Argument Argument Description
Name Type name Type
Prints the matrix in a row-
displayMatrix() void matrix int[][]
wise format
Sorts the elements of a row
bubbleSort() void row int[] in ascending order using the
bubble sort algorithm
Main entry point of the
main() void - - program; calls the methods
to sort the rows of the matrix
Program No.3
Variable List
Variable Type Description
Name
N int Number of teams entered by the user
Function Description:
Function Return Argument Argument Description
Name Type name Type
Prints the team names
args[], vertically, side by side with a
verticalDisplay() void String, int, int
maxLength, N horizontal tab between each
team name
Main entry point of the
program; calls the methods
main() void - -
to display the names of
teams in vertical form
Program No.4
Variable List
Variable Type Description
Name
word String Static variable to store a word
Array to store the words extracted from the
words String[]
sentence
Used in bubble sort algorithm to track if any swaps
swapped boolean
were made during on iteration
Used in ‘calculatePotential()’ method to store the
potential int
cumulative potential of a word
scanner Scanner Scanner object for reading user input.
Function Description:
Function Return Argument Argument Description
Name Type name Type
Calculates and returns the
calculatePotential() int word String
potential of a given word
Processes the input sentence
by removing the termination
processSentence() String[] sentence String
character and splitting it into
an array of words.
Sorts an array of words in
sortsWordsByPotential() void words String[][] ascending order based on
their potential.
Main entry point of the
program; calls the methods
main() void - - to calculate the words
according to their potential
in ascending order.
Program No.5
Variable List
Type Description
Variable Name
Function Description:
Function Return Argument Argument Description
Name Type name Type
Converts an integer num to
decimalToBinary() String num int its binary representation of
integer.
Counts the number of 1s in
countOnesInBinary() int num int the binary representation of
integer num.
Checks if the integer ‘num’ is
an Evil number by counting
the 1s in its binary
isEvilNumber() boolean num int
representation and
determining if the count is
even.
Main entry point of the
program; calls the methods
to find the binary
main() void - -
representation of a number
and checks if the number is
Evil number or not.