Variable Listing for Java Programs
1) Twisted Prime
Variable Name Data Type Purpose
n int Stores the input number
sc Scanner To take input from user
r int Stores the reverse of the
number
i int Loop control variable
c int Counts factors for prime
check
2) Abundant Number
Variable Name Data Type Purpose
l int Lower range input
u int Upper range input
sc Scanner To take input from user
i int Loop control variable
s int Stores sum of factors
n int Number to check abundant
3) Sum of Largest and Smallest Digit
Variable Name Data Type Purpose
n int Stores 5-digit input number
sc Scanner To take input
l int Stores largest digit
s int Stores smallest digit
c int Counts factors to check
composite
i int Loop control variable
4) Switch Pattern
Variable Name Data Type Purpose
n int Choice for pattern type
sc Scanner To take input
l int Number of lines
i int Outer loop counter
j int Inner loop counter
5) Series Pattern Sum
Variable Name Data Type Purpose
a int Stores value of a
n int Number of terms
sum double Stores sum of series
fact double Stores factorial value
sign int Stores +1/-1 for alternating
sign
i int Loop control variable
j int Loop control for factorial
6) Pattern Overload
Variable Name Data Type Purpose
r int Number of rows
x char Character for pattern
rows int User input for rows
character2 char User input character
choice int Menu choice
i int Loop variable
j int Nested loop variable
k int Used for increment in
pattern
8) Bill Program
Variable Name Data Type Purpose
bno int Bill number
call int Number of calls
amt double Bill amount
name String Customer name
b int User entered bill number
calls int User entered calls
n String User entered name
9) Largest, 2nd Largest, Square Root Sum
Variable Name Data Type Purpose
n int Array size
a[] int[] Array of elements
sc Scanner To take input
max int Largest element
min int Smallest element
max2 int Second largest element
s int Sum of positive numbers
i int Loop control variable
10) Merge Two Arrays
Variable Name Data Type Purpose
m int Size of first array
n int Size of second array
P[] int[] First array
Q[] int[] Second array
R[] int[] Merged array
k int Index for merged array
i int Loop control
t int Temporary variable for
swapping
min int Index of smallest element