Skip to content

Commit a32bcd4

Browse files
committed
closed all the sc.scanners & added some files.
1. all sc.scanners closed from folder 1-7 (JFO_1_5_*.java) 2. addes decimal to binary convertion methods (2)
1 parent 1a1bf37 commit a32bcd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+115
-15
lines changed

1.Basics/JB_4_Input.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public static void main(String[] args) {
4747
// ..
4848
// nextFolat()
4949
// nextDouble()
50+
sc.close();
5051
}
5152
}
5253

1.Basics/JB_5_Sum2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ public static void main(String[] args) {
1919
System.out.println(sum);
2020
System.out.println("the product of the two numvers is ");
2121
System.out.println(multyply);
22+
sc.close();
2223
}
2324
}

1.Basics/JB_6_AreaofCircle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public static void main(String[] args) {
1212
float a = sc.nextFloat();
1313
float radius = 3.14f * a * a;
1414
System.out.println(radius);
15+
sc.close();
1516
}
1617
}

1.Basics/JB_7_TypeCasting.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* ==================================================================================================================================================
44
* JB_7_TypeCasting
55
*
6-
* PERF:
6+
* GREEN:
77
* A.Type Conversion or( Widening or Implicit(unclear) converison...)
88
* B.Type Casting or (Narrowing or Explicit(clear) converison...)
99
*
@@ -47,7 +47,7 @@ public static void main(String[] args) {
4747

4848
// eg. 2
4949
Scanner sc = new Scanner(System.in);
50-
int eg2_a = sc.nextFloat(); // this is giving error type mismatched type
50+
float eg2_a = sc.nextFloat(); // this is giving error type mismatched type
5151
// cannot convert from float ot int...
5252

5353
float eg2_b = sc.nextInt(); // whereas this will work without doubt cos flot is 8bit and we are saving int
@@ -90,5 +90,6 @@ public static void main(String[] args) {
9090
//
9191
//
9292
//
93+
sc.close();
9394
}
9495
}

1.Basics/JB_8_2_ExpressionPromotion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ public class JB_8_2_ExpressionPromotion {
1313

1414
public static void main(String[] args) {
1515
byte a = 3;
16-
byte b = a * 2;
16+
int b = a * 2;
1717
// see the warning its becouse a is now premoted into Int.
1818

1919
// so we use typecast here
2020
byte c = (byte) (a * 2);
2121
System.out.println(c);
22+
2223
}
2324
}

2.Operators/JOP_1_Operators.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// TODO:
2+
// BLUE:
33
// OPERANDS and OPERATOR
44
// "a, b,and var is OPERANDS".
55
// Symbols that tell compiler to perform certain operation. ( +,-,*,/ )
@@ -16,12 +16,12 @@
1616
public class JOP_1_Operators {
1717
public static void main(String[] args) {
1818

19-
// FIX:
19+
// BLUE:
2020
// 1 Arithmetic operators:
2121
// TEST:
2222
// A. Unary operators
2323
// only one operand eg. a++ , b-- , ++c, --d;
24-
// FIX:[here a += 10 and a-= 12; are considerd as assigment operators so chechk
24+
// WARN:[here a += 10 and a-= 12; are considerd as assigment operators so chechk
2525
// there.]
2626
// TEST:
2727
// B. Binary operators:
@@ -38,7 +38,7 @@ public static void main(String[] args) {
3838

3939
// FIX:
4040
// 2 Relational Operator:
41-
// TEST:
41+
// DIV:
4242
// shows relation ---
4343
// 1. ==
4444
// 2. !=
@@ -63,7 +63,7 @@ public static void main(String[] args) {
6363
System.out.println("A >= B is " + (A >= B));
6464
System.out.println("A <= B is " + (A <= B));
6565

66-
// FIX:
66+
// TAG:
6767
// Assignment operators
6868
// 1. =
6969
// 2. +=

3.ConditionalSteatments/JCS_1_IfEsle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static void main(String[] args) {
2121
// FIX:
2222
// here if we use only if instead of else if, in cases where age is "18" both
2323
// conditions might be applied ( if we use age <= 18 in second case.).
24+
sc.close();
2425
}
2526

2627
}

3.ConditionalSteatments/JCS_2_IfElse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ public static void main(String[] args) {
1717
} else {
1818
System.out.println(" b is greater !!!");
1919
}
20+
sc.close();
2021
}
2122
}

3.ConditionalSteatments/JCS_3_IfElse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public static void main(String[] args) {
1414
} else {
1515
System.out.println("The value of a " + a + " is Odd Value.");
1616
}
17+
sc.close();
1718
}
18-
1919
}

3.ConditionalSteatments/JCS_4_ifelseTax.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public static void main(String[] args) {
2121
int grossIncome = income - tax;
2222
System.out.println("accouding to your income '" + income + "' your income tax is = " + tax);
2323
System.out.println("hence your Real income is " + grossIncome);
24-
24+
sc.close();
2525
}
2626
}

3.ConditionalSteatments/JCS_5_ifelse_largeNum.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@ public static void main(String[] args) {
3737
} else {
3838
System.out.println("the 3rd input " + a3 + " is greatest of all !!!");
3939
}
40+
sc.close();
4041
}
4142
}

3.ConditionalSteatments/JCS_6_terneryOperator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ public static void main(String[] args) {
3333

3434
System.out.println((val1 >= val2) ? "Congruats You are pass !!!" : "Your Score is low, Better Luck Next Time.");
3535
// here we added turnery opeartor insdide the println() function.
36+
sc.close();
3637
}
3738
}

3.ConditionalSteatments/JCS_7_SwitchCalculator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ public static void main(String[] args) {
3838
System.out.println("inValid Operator is given please give only +,-,*,/,%");
3939
break;
4040
}
41+
sc.close();
4142
}
4243
}

3.ConditionalSteatments/JCS_Assi1.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ public static void main(String[] args) {
1515
String posNigitie = (num > 0) ? "Positive" : "Nigitive";
1616

1717
System.out.println("The Number " + num + " is " + evenOdd + " && " + posNigitie + " Number.");
18+
sc.close();
1819
}
1920
}

3.ConditionalSteatments/JCS_Assi2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ public static void main(String[] args) {
3636
System.out.println("Please enter only 1 to 7 days according day.");
3737
break;
3838
}
39+
sc.close();
3940
}
4041
}

3.ConditionalSteatments/JCS_Assi3.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ public static void main(String[] args) {
2222
}
2323
System.out.println("With this the loop is ended.");
2424

25+
sc.close();
2526
}
2627
}

3.ConditionalSteatments/JCS_Assi4.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ public static void main(String[] args) {
2121
} else {
2222
System.err.println("ERROR: Please make sure Initial value is smaller than Final Value. !!!");
2323
}
24+
sc.close();
2425
}
2526
}

3.ConditionalSteatments/JCS_Assi4_2.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ public static void main(String[] args) {
1818
float sum = (initVal + finVal) * (finVal - initVal) / 2;
1919

2020
System.out.println(sum);
21+
sc.close();
2122
}
2223
}

4.Loops/JL_1_while.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ public static void main(String[] args) {
1313
x++;
1414
}
1515
System.out.println("End.");
16+
sc.close();
1617
}
1718
}

4.Loops/JL_2_forLoop.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public static void main(String[] args) {
1111
System.out.println("I dont know wahat is this !!! " + for1);
1212
}
1313
System.out.println("End.");
14+
sc.close();
1415
}
1516
}

4.Loops/JL_3_sumOfN.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public static void main(String[] args) {
1010
sum = sum + i;
1111
}
1212
System.out.println("The total = " + sum);
13+
sc.close();
1314
}
1415
}

4.Loops/JL_4_reverseNum.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ public static void main(String[] args) {
1515
n = n / 10;
1616
}
1717
System.out.println("The reverse of " + orignal + " is " + rev);
18+
sc.close();
1819
}
1920
}

4.Loops/JL_5_doWhileBREAK.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public static void main(String[] args) {
1212
}
1313
System.out.println(num);
1414
} while (true);
15+
sc.close();
1516
}
1617
}

4.Loops/JL_6_doWhileContinue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public static void main(String[] args) {
3030
i++;
3131
}
3232
} while (i <= a);
33-
33+
sc.close();
3434
}
3535
}

5.BasicDeep/JBD_1_primeNum.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public static void main(String[] args) {
99
Boolean prime = true;
1010
if (checkNum == 2) {
1111
System.out.println("The number " + checkNum + " is Prime number!!!");
12+
sc.close();
1213
return;
1314
} else {
1415
for (int i = 2; i <= Math.sqrt(checkNum); i++) {
@@ -26,6 +27,7 @@ public static void main(String[] args) {
2627
System.out.println("The number " + checkNum + " is NOT a Prime number!!!");
2728
}
2829
}
30+
sc.close();
2931
}
3032
}
3133

5.BasicDeep/JBD_2_evenOddSepretSum.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ public static void main(String[] args) {
2424
} while (repet == 1);
2525

2626
System.out.println(" The total of all Evens is: " + Even + " and The total of all ODDS is: " + Odd);
27+
sc.close();
2728
}
2829
}

5.BasicDeep/JL_Pat_1_lines.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ public static void main(String[] args) {
99
for (int i = 0; i < line; i++) {
1010
System.out.println("****");
1111
}
12+
sc.close();
1213
}
1314
}

5.BasicDeep/JL_Pat_2_stars.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public static void main(String[] args) {
1717
start++; // PERF: this must be in the while loop other wise it will be incrementino
1818
// everytime in for loop and loop will stop very soon.
1919
}
20-
;
20+
sc.close();
2121
}
2222
}

5.BasicDeep/JL_Pat_3_revPat.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ public static void main(String[] args) {
1515
System.out.println(" ");
1616
}
1717

18+
sc.close();
1819
}
1920
}

5.BasicDeep/JL_Pat_4_charPat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public static void main(String[] args) {
1616
}
1717
System.out.println();
1818
}
19-
19+
sc.close();
2020
}
2121
}

5.BasicDeep/JL_Pat_5_numPirimid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public static void main(String[] args) {
1616
}
1717
System.out.println();
1818
}
19-
19+
sc.close();
2020
}
2121
}

6.Function_Methods/JFM_1_funBasic.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@ public static void main(String[] args) {
4646
// in INT return type we have to use "return <name>;" stetment so that it can
4747
// return certain value.
4848
// wihtout that it will through error.
49+
sc.close();
4950
}
5051
}

6.Function_Methods/JFM_2_funBasic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public static void main(String[] args) {
1919

2020
int multi = multiply(a, b);
2121
System.out.println(multi);
22-
22+
sc.close();
2323
}
2424
}

6.Function_Methods/JFM_3_valSWAP.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ public static void main(String[] args) {
3434
System.out.println("value of A and B respectively in MAIN function " + a + " " + b);
3535
System.out.println(
3636
"The resualt shows how jawa uses 'Pass by value' to copy the variables in other method/function/stack");
37+
sc.close();
3738
}
3839
}

6.Function_Methods/JFM_4_factorial.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ public static void main(String[] args) {
2020

2121
int fact = factorial(a);
2222
System.out.println("The factorial of " + a + " is " + fact);
23+
sc.close();
2324
}
2425
}

6.Function_Methods/JFM_5_binomialCofiecient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static void main(String[] args) {
3636

3737
int binoCofi = binomialCofient(n, r);
3838
System.out.println("the Binomial Cofient of " + n + " and " + r + " is " + binoCofi);
39+
sc.close();
3940

4041
}
4142
}

7.Function_Overloading/'

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.*;
2+
3+
public class JL_4_reverseNum {
4+
public static void main(String[] args) {
5+
6+
Scanner sc = new Scanner(System.in);
7+
System.out.println("Please input the number:");
8+
int n = sc.nextInt();
9+
int orignal = n;
10+
int rev = 0;
11+
12+
while (n > 0) {
13+
int x = n % 10;
14+
rev = (rev * 10) + x;
15+
n = n / 10;
16+
}
17+
System.out.println("The reverse of " + orignal + " is " + rev);
18+
sc.close();
19+
}
20+
}

7.Function_Overloading/JFO_1_1_A_ParamNum.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ public static int inputAdder() {
3636
System.out.println("Intput d: (max num = 4)");
3737
int d = sc.nextInt();
3838
int res = multiply(a, b, c, d);
39+
sc.close();
3940
return res;
4041
} else {
4142
int res = multiply(a, b, c);
43+
sc.close();
4244
return res;
4345
}
4446
} else {
4547
int res = multiply(a, b);
48+
sc.close();
4649
return res;
4750
}
4851
}

7.Function_Overloading/JFO_1_2_PrimeCheck.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,7 @@ public static void main(String[] args) {
3939
}
4040
startNum++;
4141
} while (startNum <= endNum);
42+
43+
sc.close();
4244
}
4345
}
Binary file not shown.

0 commit comments

Comments
 (0)