Skip to content

Commit 4bb145c

Browse files
committed
lint fix
1 parent 11aeb3f commit 4bb145c

File tree

6 files changed

+66
-69
lines changed

6 files changed

+66
-69
lines changed

FAT-Practice/src/Donations.java

+13-15
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void display() {
2626
}
2727

2828
public class Donations {
29-
public static int getMonths(Date start, Date end){
29+
public static int getMonths(Date start, Date end) {
3030
Calendar startCal = new GregorianCalendar();
3131
startCal.setTime(start);
3232
Calendar endCal = new GregorianCalendar();
@@ -42,52 +42,50 @@ public static void main(String[] args) {
4242
Scanner sc = new Scanner(System.in);
4343
Donor donors[] = new Donor[3];
4444

45-
try{
45+
try {
4646
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
4747
donors[0] = new Donor("Anuradha", "2172", "O+ve", sdf.parse("13/09/2018"), 21);
48-
donors[1] = new Donor("Uday", "2012", "AB+ve",sdf.parse("12/05/2018"), 21);
48+
donors[1] = new Donor("Uday", "2012", "AB+ve", sdf.parse("12/05/2018"), 21);
4949
donors[2] = new Donor("Kaviya", "0888", "A+ve", sdf.parse("12/04/2018"), 21);
50-
}catch (ParseException e){
50+
} catch (ParseException e) {
5151
System.out.println(e);
5252
}
5353

5454
String filename = "donations.txt";
55-
try{
55+
try {
5656
FileOutputStream fos = new FileOutputStream(filename);
5757
ObjectOutputStream oos = new ObjectOutputStream(fos);
5858

5959
oos.writeObject(donors);
6060
oos.close();
6161
fos.close();
62-
}catch(FileNotFoundException e){
62+
} catch (FileNotFoundException e) {
6363
System.out.println(e);
64-
}catch(IOException e){
64+
} catch (IOException e) {
6565
System.out.println(e);
6666
}
6767

68-
try{
68+
try {
6969
FileInputStream fis = new FileInputStream(filename);
7070
ObjectInputStream ois = new ObjectInputStream(fis);
7171

72-
Donor[] savedDonors = (Donor[])ois.readObject();
72+
Donor[] savedDonors = (Donor[]) ois.readObject();
7373

7474
fis.close();
7575
ois.close();
7676

7777
System.out.println("Donors with A+ve and Last date of Donation > 6mths: ");
78-
for(Donor d: savedDonors) {
79-
if(getMonths(d.dold,new Date()) > 6 && d.bgroup.equals("A+ve"))
78+
for (Donor d : savedDonors) {
79+
if (getMonths(d.dold, new Date()) > 6 && d.bgroup.equals("A+ve"))
8080
d.display();
8181
}
82-
}catch(FileNotFoundException e){
82+
} catch (FileNotFoundException e) {
8383
System.out.println(e);
84-
}catch(IOException e){
84+
} catch (IOException e) {
8585
System.out.println(e);
8686
} catch (ClassNotFoundException e) {
8787
e.printStackTrace();
8888
}
8989

90-
91-
9290
}
9391
}

FAT-Practice/src/ISBN.java

+6-8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import java.util.Scanner;
44

5-
class InvalidInputException extends Exception{
6-
InvalidInputException(String msg){
5+
class InvalidInputException extends Exception {
6+
InvalidInputException(String msg) {
77
super(msg);
88
}
99
}
@@ -12,19 +12,17 @@ public class ISBN {
1212
public static void main(String[] args) {
1313
Scanner sc = new Scanner(System.in);
1414
String is = sc.nextLine();
15-
try{
16-
if(is.length() != 9){
15+
try {
16+
if (is.length() != 9) {
1717
throw new InvalidInputException("ISBN must be exactly 9 digits");
18-
}
19-
else{
18+
} else {
2019
NumberManipulation n = new NumberManipulation();
2120
Integer i = Integer.parseInt(is);
2221
n.extractDigits(i);
2322
System.out.println("Last digit = " + n.findLastDigit());
2423
System.out.println("New ISBN = " + is + n.findLastDigit());
2524
}
26-
}
27-
catch(Exception e){
25+
} catch (Exception e) {
2826
System.out.println(e);
2927
}
3028
}

FAT-Practice/src/MapsPractice.java

+19-19
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,41 @@ public static void main(String[] args) {
1111

1212
// creating list of subjects and adding to hash map
1313
List<String> subjects = Arrays.asList("Python", "Math", "C");
14-
h1.put("A",subjects);
15-
subjects = Arrays.asList("C","C++");
16-
h1.put("B",subjects);
17-
subjects = Arrays.asList("C++","Physics","Chemistry");
18-
h1.put("C",subjects);
14+
h1.put("A", subjects);
15+
subjects = Arrays.asList("C", "C++");
16+
h1.put("B", subjects);
17+
subjects = Arrays.asList("C++", "Physics", "Chemistry");
18+
h1.put("C", subjects);
1919

2020
// creating hashmap of faculty
21-
h2.put("Python","111");
22-
h2.put("Math","222");
23-
h2.put("C","333");
24-
h2.put("C++","444");
21+
h2.put("Python", "111");
22+
h2.put("Math", "222");
23+
h2.put("C", "333");
24+
h2.put("C++", "444");
2525

2626
// displaying all students and subjects
27-
for(Map.Entry m:h1.entrySet()){
27+
for (Map.Entry m : h1.entrySet()) {
2828
System.out.println(m.getKey());
29-
subjects = (List<String>)m.getValue();
30-
for(String s:subjects)
29+
subjects = (List<String>) m.getValue();
30+
for (String s : subjects)
3131
System.out.print(s + " ");
3232
System.out.println();
3333
}
3434
// displaying all subjects and faculty
35-
for(Map.Entry m:h2.entrySet()){
36-
System.out.println(m.getKey()+" "+m.getValue());
35+
for (Map.Entry m : h2.entrySet()) {
36+
System.out.println(m.getKey() + " " + m.getValue());
3737
}
3838

3939
// Scanner sc = new Scanner(System.in);
4040
// System.out.print("Enter a student: ");
4141
String s = "B";
4242

4343
System.out.println("Faculties are: ");
44-
for(Map.Entry m:h1.entrySet()){
45-
if(m.getKey().equals(s)){
46-
for(Map.Entry m2:h2.entrySet()){
47-
subjects = (List<String>)m.getValue();
48-
if(subjects.contains(m2.getKey()))
44+
for (Map.Entry m : h1.entrySet()) {
45+
if (m.getKey().equals(s)) {
46+
for (Map.Entry m2 : h2.entrySet()) {
47+
subjects = (List<String>) m.getValue();
48+
if (subjects.contains(m2.getKey()))
4949
System.out.println(m2.getValue());
5050
}
5151
}

FAT-Practice/src/Package1/NumberManipulation.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ public class NumberManipulation {
44
int i;
55
int arr[] = new int[9];
66

7-
public void extractDigits(int num){
7+
public void extractDigits(int num) {
88

9-
for(i = 8; i >= 0; i--){
10-
arr[i] = num%10;
11-
num = num/10;
9+
for (i = 8; i >= 0; i--) {
10+
arr[i] = num % 10;
11+
num = num / 10;
1212
}
1313
}
1414

15-
public int findLastDigit(){
15+
public int findLastDigit() {
1616
int n = 1, sum = 0;
1717

18-
for(i = 0; i < 9; i++) {
19-
sum += arr[i]*n;
18+
for (i = 0; i < 9; i++) {
19+
sum += arr[i] * n;
2020
n++;
2121
}
2222

FAT-Practice/src/VITHonors.java

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import java.util.Vector;
22

3-
class Attendance{
3+
class Attendance {
44
static int winners = 0;
55
static Vector<Integer> arr = new Vector<>();
66

7-
static synchronized void counting(int n){
7+
static synchronized void counting(int n) {
88
System.out.println(Thread.currentThread().getName() + " is counting");
9-
for(int i = n-1000; i < n; i++){
10-
if(arr.get(i) == 100)
9+
for (int i = n - 1000; i < n; i++) {
10+
if (arr.get(i) == 100)
1111
winners++;
1212
}
1313
}
1414
}
1515

16-
class count extends Thread{
16+
class count extends Thread {
1717
int n;
1818

19-
count(int n){
19+
count(int n) {
2020
this.n = n;
2121
}
22-
public void run(){
22+
23+
public void run() {
2324
Attendance.counting(n);
2425
}
2526
}
@@ -30,8 +31,8 @@ public static void main(String[] args) {
3031
int max = 100;
3132
int min = 75;
3233

33-
for(int i = 0; i < 2000; i++){
34-
int n = (int)(Math.random() * ((max - min) + 1) + min);
34+
for (int i = 0; i < 2000; i++) {
35+
int n = (int) (Math.random() * ((max - min) + 1) + min);
3536
Attendance.arr.add(n);
3637
}
3738

@@ -40,10 +41,10 @@ public static void main(String[] args) {
4041
t1.start();
4142
t2.start();
4243

43-
try{
44+
try {
4445
t1.join();
4546
t2.join();
46-
}catch(InterruptedException e){
47+
} catch (InterruptedException e) {
4748
System.out.println(e);
4849
}
4950

FAT-Practice/src/volunteers.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,35 @@ public static void main(String[] args) {
99

1010
System.out.println("Selecting batch 1 students: ");
1111
batches[0] = new String[4];
12-
for(i = 0; i < 4; i++){
13-
System.out.print("Enter reg. no. " + (i+1) + ": ");
12+
for (i = 0; i < 4; i++) {
13+
System.out.print("Enter reg. no. " + (i + 1) + ": ");
1414
batches[0][i] = sc.nextLine();
1515
}
1616

1717
System.out.println("Selecting batch 2 students: ");
1818
batches[1] = new String[3];
19-
for(i = 0; i < 3; i++){
20-
System.out.print("Enter reg. no. " + (i+1) + ": ");
19+
for (i = 0; i < 3; i++) {
20+
System.out.print("Enter reg. no. " + (i + 1) + ": ");
2121
batches[1][i] = sc.nextLine();
2222
}
2323

2424
System.out.println("Selecting batch 1 students: ");
2525
batches[2] = new String[1];
26-
for(i = 0; i < 1; i++){
27-
System.out.print("Enter reg. no. " + (i+1) + ": ");
26+
for (i = 0; i < 1; i++) {
27+
System.out.print("Enter reg. no. " + (i + 1) + ": ");
2828
batches[2][i] = sc.nextLine();
2929
}
3030

3131
System.out.println("\n" + "Batch 1 students are: ");
32-
for(i = 0; i < 4; i++)
32+
for (i = 0; i < 4; i++)
3333
System.out.print(batches[0][i] + "\t");
3434

3535
System.out.println("\n" + "Batch 2 students are: ");
36-
for(i = 0; i < 3; i++)
36+
for (i = 0; i < 3; i++)
3737
System.out.print(batches[1][i] + "\t");
3838

3939
System.out.println("\n" + "Batch 3 students are: ");
40-
for(i = 0; i < 1; i++)
40+
for (i = 0; i < 1; i++)
4141
System.out.print(batches[2][i] + "\t");
4242
}
4343
}

0 commit comments

Comments
 (0)