0% found this document useful (0 votes)
11 views5 pages

First 5

The document outlines five different programs, each with variable lists and function descriptions. Each program serves a specific purpose, such as packing boxes, displaying matrices, showing team names, calculating word potential, and determining if a number is an Evil number. The programs utilize various data types and methods for user input and processing.

Uploaded by

nascarjeet00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

First 5

The document outlines five different programs, each with variable lists and function descriptions. Each program serves a specific purpose, such as packing boxes, displaying matrices, showing team names, calculating word potential, and determining if a number is an Evil number. The programs utilize various data types and methods for user input and processing.

Uploaded by

nascarjeet00
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Program No.

Variable List
Variable Type Description
Name
N int No. of boxes to be packed

T int Used to store the original value “N”

c48 int No. of cartons of size 48 used

c24 int No. of cartons of size 24 used

c12 int No. of cartons of size 12 used

c6 int No. of cartons of size 6 used

total int Total no. of cartons used

scanner Scanner Scanner object for reading user input.

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

n int Number of columns in the matrix

matrix int[][] 2D array that stores the matrix elements

scanner Scanner Scanner object for reading user input.

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

teams String[] Array of teams names

maxLength int Maximum length of the team names

scanner Scanner Scanner object for reading user input.

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

N int Stores the user provided number after validation.

binaryRepresentation String Stores the binary representation of N


Stores the count of 1s in the binary representation
onesCount int
of N.
Indicates whether N is an Evil number(true) or not
isEvil boolean
(false).
scanner Scanner Scanner object for reading user input.

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.

You might also like