Skip to content

Commit db79de6

Browse files
committed
margins fixed
1 parent c8258bf commit db79de6

19 files changed

+150
-110
lines changed
Binary file not shown.

src/com/sbiswas001/twelveproject/AlphabeticalSentence.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import java.util.Scanner;
44

55
/**
6-
* This class enters multiple strings from user and arranges them in ascending order.
6+
* This class enters multiple strings from user and arranges
7+
* them in ascending order.
78
* @author Sayan Biswas
89
* @version 08.04.2022
910
*/
@@ -28,7 +29,7 @@ private void input() {
2829
System.out.print("Enter number of strings: ");
2930
//Deals with InputMismatchException
3031
if(!sc.hasNextInt()){
31-
System.out.print("Wrong datatype; enter a number: ");
32+
System.out.print("Wrong input! Enter a number: ");
3233
input();
3334
}
3435
int x=Integer.parseInt(sc.next());
@@ -48,7 +49,8 @@ private void compute(String[] a) {
4849
//Bubble sort technique
4950
for (int i = 0; i < a.length; i++) {
5051
for (int j = i + 1; j < a.length; j++) {
51-
if (a[i].toUpperCase().compareTo(a[j].toUpperCase())>0) {
52+
if (a[i].toUpperCase().
53+
compareTo(a[j].toUpperCase())>0) {
5254
temp = a[i];
5355
a[i] = a[j];
5456
a[j] = temp;

src/com/sbiswas001/twelveproject/ArmstrongNumber.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
/**
66
* Checks if a number is armstrong or not.
7-
* A number is armstrong if the sum of each
8-
* digit to the power number of digits is
9-
* equal to the number itself.
7+
* A number is armstrong if the sum of each digit to the power
8+
* number of digits is equal to the number itself.
109
* @author Sayan Biswas
1110
* @version 25.04.2022
1211
*/
@@ -43,16 +42,16 @@ private int numberOfDigits(int n) {
4342

4443
/**
4544
* Checks if a number is armstrong or not.
46-
* A number is armstrong if the sum of each
47-
* digit to the power number of digits is
48-
* equal to the number itself.
45+
* A number is armstrong if the sum of each digit to the
46+
* power number of digits is equal to the number itself.
4947
* @param a Number to be checked
5048
* @return true or false
5149
*/
5250
private boolean armstrongCheck(int a) {
5351
int sum = 0;
5452
while(a > 0) {
55-
sum += (int)Math.pow(a % 10, numberOfDigits(number));
53+
sum += (int)Math.pow(a % 10,
54+
numberOfDigits(number));
5655
a /= 10;
5756
}
5857
return sum == number;

src/com/sbiswas001/twelveproject/AscendingOrder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Scanner;
44

55
/**
6-
* This class inputs an array of integers
7-
* and sorts them in ascending order.
6+
* This class inputs an array of integers and sorts them in
7+
* ascending order.
88
* @author Sayan Biswas
99
* @version 22.04.2022
1010
*/

src/com/sbiswas001/twelveproject/DateRepresentation.java

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ private DateRepresentation() {
6767
suffix = "";
6868
oldDate = 0;
6969
daysAfter = 0;
70-
monthNames = new String[]{"JANUARY", "FEBRUARY", "MARCH",
71-
"APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER",
72-
"OCTOBER", "NOVEMBER", "DECEMBER"};
73-
monthDays = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
70+
monthNames = new String[]{"JANUARY", "FEBRUARY",
71+
"MARCH", "APRIL", "MAY", "JUNE", "JULY",
72+
"AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER",
73+
"DECEMBER"};
74+
monthDays = new int[]{31, 28, 31, 30, 31, 30, 31, 31,
75+
30, 31, 30, 31};
7476
}
7577

7678
/**
@@ -83,13 +85,14 @@ private void input() {
8385
System.out.print("Enter year(4 digits): ");
8486
year = Integer.parseInt(sc.next());
8587
if (year < 1000 || year > 9999) {
86-
System.out.println("Try again! Year must be of 4 digits.");
88+
System.out.println("Try again! " +
89+
"Year must be 4 digits.");
8790
input();
8891
}
8992
System.out.print("Enter increment after old date: ");
9093
increment = Integer.parseInt(sc.next());
9194
if (increment < 1 || increment > 100) {
92-
System.out.println("Try again! Range is 1 to 100.");
95+
System.out.println("Try again! Range 1 to 100.");
9396
input();
9497
}
9598
}
@@ -99,7 +102,8 @@ private void input() {
99102
*/
100103
private void oldDateCalculator() {
101104
//February should have 29 days if it is leap year
102-
if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))
105+
if (year % 400 == 0 ||
106+
(year % 100 != 0 && year % 4 == 0))
103107
monthDays[1] = 29;
104108

105109
oldDate = days;
@@ -111,7 +115,8 @@ private void oldDateCalculator() {
111115
if (i == 12) {
112116
i = 0;
113117
year++;
114-
if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
118+
if (year % 400 == 0 ||
119+
(year % 100 != 0 && year % 4 == 0)) {
115120
monthDays[1] = 29;
116121
}
117122
}
@@ -143,19 +148,23 @@ private void newDateCalculator() {
143148
if (i == 12) {
144149
i = 0;
145150
year++;
146-
if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
151+
if (year % 400 == 0 ||
152+
(year % 100 != 0 && year % 4 == 0)) {
147153
monthDays[1] = 29;
148154
}
149155
}
150156
}
151157
//Adding suffix as per day
152158
if (daysAfter % 10 == 1 && daysAfter / 10 != 1) {
153159
suffix = "ST";
154-
} else if (daysAfter % 10 == 2 && daysAfter / 10 != 1) {
160+
}
161+
else if (daysAfter % 10 == 2 && daysAfter / 10 != 1) {
155162
suffix = "ND";
156-
} else if (daysAfter % 10 == 3 && daysAfter / 10 != 1) {
163+
}
164+
else if (daysAfter % 10 == 3 && daysAfter / 10 != 1) {
157165
suffix = "RD";
158-
} else {
166+
}
167+
else {
159168
suffix = "TH";
160169
}
161170
}
@@ -168,10 +177,12 @@ public static void main(String[] args) {
168177
DateRepresentation ob = new DateRepresentation();
169178
ob.input();
170179
ob.oldDateCalculator();
171-
System.out.println("Old date: " + ob.oldDate + ob.suffix + " " +
172-
ob.monthNames[ob.monthIndex] + " " + ob.year);
180+
System.out.println("Old date: " + ob.oldDate +
181+
ob.suffix + " " + ob.monthNames[ob.monthIndex]
182+
+ " " + ob.year);
173183
ob.newDateCalculator();
174-
System.out.println("New date: " + ob.daysAfter + ob.suffix + " " +
175-
ob.monthNames[ob.monthIndex] + " " + ob.year);
184+
System.out.println("New date: " + ob.daysAfter +
185+
ob.suffix + " " + ob.monthNames[ob.monthIndex]
186+
+ " " + ob.year);
176187
}
177188
}

src/com/sbiswas001/twelveproject/FibonacciSeries.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
import java.util.Scanner;
44

55
/**
6-
* This class prints n terms of the fibonacci series specified by user.
7-
* In fibonacci series, next number is the sum of previous two numbers.
6+
* This class prints n terms of the fibonacci series.
7+
* In fibonacci series, next number is the sum of previous
8+
* two numbers.
89
* @author Sayan Biswas
910
* @version 06.04.2022
1011
*/

src/com/sbiswas001/twelveproject/GCD.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Scanner;
44

55
/**
6-
* This class calculates the greatest common divisor
7-
* of two numbers.
6+
* This class calculates the greatest common divisor of two
7+
* numbers.
88
* @author Sayan Biswas
99
* @version 23.04.2022
1010
*/
@@ -61,7 +61,8 @@ private int setGCD(int a, int b) {
6161
public static void main(String[] args) {
6262
GCD ob = new GCD();
6363
ob.input();
64-
System.out.println("GCD is " + ob.setGCD(ob.num1, ob.num2));
64+
System.out.println("GCD is " +
65+
ob.setGCD(ob.num1, ob.num2));
6566
}
6667

6768
}

src/com/sbiswas001/twelveproject/Initials.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import java.util.Scanner;
55

66
/**
7-
* This class enters a name from user and
8-
* prints out the initials.
7+
* This class enters a name from user and prints out the
8+
* initials.
99
* @author Sayan Biswas
1010
* @version 23.04.2022
1111
*/
@@ -47,7 +47,8 @@ private void setInitials() {
4747
initials.add(name.charAt(i+1) + ". ");
4848
}
4949
}
50-
initials.add(name.substring(name.lastIndexOf(' ')));
50+
initials.add(name.substring(
51+
name.lastIndexOf(' ')));
5152
}
5253

5354
/**

src/com/sbiswas001/twelveproject/LinearSearch.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
/**
66
* This class checks if a term is in an array.
7-
* If found it displays appropriate message along
8-
* with index number of the term.
7+
* If found it displays appropriate message along with index
8+
* number of the term.
99
* @author Sayan Biswas
1010
* @version 20.04.2022
1111
*/
@@ -44,7 +44,7 @@ private void input() {
4444
System.out.print("Enter the number of elements: ");
4545
arrayLength = Integer.parseInt(sc.nextLine());
4646
arr = new int[arrayLength];
47-
System.out.println("Enter the elements of the array: ");
47+
System.out.println("Enter the elements of array: ");
4848
for(int i = 0; i < arrayLength; i++) {
4949
arr[i] = Integer.parseInt(sc.next());
5050
}
@@ -76,8 +76,9 @@ boolean array_search(int[] a, int x) {
7676
public static void main(String[] args) {
7777
LinearSearch ob = new LinearSearch();
7878
ob.input();
79-
System.out.println(ob.array_search(ob.arr, ob.searchTerm) ?
80-
"Element is found at index " + ob.searchTermIndex :
81-
"Element is not found.");
79+
System.out.println(
80+
ob.array_search(ob.arr, ob.searchTerm) ?
81+
"Element found at index " + ob.searchTermIndex :
82+
"Element not found.");
8283
}
8384
}

src/com/sbiswas001/twelveproject/Matrix.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* This class enters a two-dimensional matrix from the user
77
* with number of rows between 2 and 10 and prints it.
88
* It then checks if it is symmetric or not.
9-
* A square matrix is symmetric if element of the ith row
10-
* and jth column is equal to the element of jth row and ith column.
11-
* It then prints the sum of the elements of the left diagonal
12-
* and sum of elements of right diagonal.
9+
* A square matrix is symmetric if element of the ith row and
10+
* jth column is equal to the element of jth row and ith
11+
* column. It then prints the sum of the elements of the left
12+
* diagonal and sum of elements of right diagonal.
1313
* @author Sayan Biswas
1414
* @version 10.04.2022
1515
*/
@@ -57,16 +57,16 @@ private Matrix() {
5757
*/
5858
private void input() {
5959
Scanner sc = new Scanner(System.in);
60-
System.out.print("Enter the number of rows of the matrix: ");
60+
System.out.print("Enter number of rows of matrix: ");
6161
m = Integer.parseInt(sc.nextLine());
6262
if(m <= 2 || m >= 10) {
63-
System.out.print("Enter number of rows between 2 and 10: ");
63+
System.out.print("Enter number of rows(2-10): ");
6464
input();
6565
}
66-
System.out.print("Enter the number of columns of the matrix: ");
66+
System.out.print("Enter number of columns of matrix: ");
6767
n = Integer.parseInt(sc.nextLine());
6868
mat = new int[m][n];
69-
System.out.println("Enter the elements of the matrix: ");
69+
System.out.println("Enter the elements of matrix: ");
7070
for(int i = 0; i < m; i++) {
7171
for(int j = 0; j < n; j++) {
7272
mat[i][j] = Integer.parseInt(sc.next());
@@ -77,7 +77,8 @@ private void input() {
7777
/**
7878
* Checks if a matrix is symmetric.
7979
* A square matrix is symmetric if element of the ith row
80-
* and jth column is equal to the element of jth row and ith column.
80+
* and jth column is equal to the element of jth row and
81+
* ith column.
8182
* @param a Matrix to be checked
8283
* @return true or false
8384
*/
@@ -93,17 +94,17 @@ private boolean symmetricCheck(int[][] a) {
9394
}
9495

9596
/**
96-
* If matrix is a square matrix it prints the sum
97-
* of the elements of the left diagonal and sum of
98-
* elements of right diagonal.
97+
* If matrix is a square matrix it prints the sum of the
98+
* elements of the left diagonal and sum of elements of
99+
* right diagonal.
99100
* @param a Matrix to be checked
100101
*/
101102
private void diagonalSum(int[][] a) {
102103
if(m == n) {
103104
for(int i = 0; i < a.length; i++) {
104105
//Elements are like a00, a11, a22, ...
105106
leftDiagonalSum += a[i][i];
106-
//Elements are like a0((n-1)-0), a1((n-1)-1), a2((n-1)-2), ...
107+
//Elements are a0((n-1)-0), a1((n-1)-1), ...
107108
rightDiagonalSum += a[i][(a.length - 1) - i];
108109
}
109110
}
@@ -136,11 +137,15 @@ public static void main(String[] args) {
136137
System.out.println("Entered matrix is: ");
137138
ob.display(ob.mat);
138139
System.out.println(ob.symmetricCheck(ob.mat) ?
139-
"The matrix is symmetric." : "The matrix is not symmetric.");
140+
"The matrix is symmetric." :
141+
"The matrix is not symmetric.");
140142
ob.diagonalSum(ob.mat);
141143
System.out.println((ob.leftDiagonalSum == -1) ?
142-
"The matrix is not a square matrix. Hence, diagonals do not exist." :
143-
"The sum of left diagonal elements is " + ob.leftDiagonalSum + ".\n" +
144-
"The sum of right diagonal elements is " + ob.rightDiagonalSum + ".");
144+
"The matrix is not a square matrix. " +
145+
"Hence, diagonals do not exist." :
146+
"The sum of left diagonal elements is " +
147+
ob.leftDiagonalSum + ".\n" +
148+
"The sum of right diagonal elements is " +
149+
ob.rightDiagonalSum + ".");
145150
}
146151
}

0 commit comments

Comments
 (0)