Skip to content

Commit 0b0832e

Browse files
committed
Added 30 Days of Code files and Updated ReadMe
1 parent ce64ed5 commit 0b0832e

34 files changed

+311
-57
lines changed

.vscode/settings.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"java.project.sourcePaths": [
3+
"30DaysOfCode",
4+
"Java\\Big Number",
5+
"Java\\Data Structures",
6+
"Java\\Exception Handling",
7+
"Java\\Introduction",
8+
"Java\\OOP",
9+
"Java\\Others",
10+
"Java\\Strings"
11+
]
12+
}

30DaysOfCode/Day00.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.*;
2+
public class Day00 {
3+
public static void main(String[] args) {
4+
// Create a Scanner object to read input from stdin.
5+
Scanner scan = new Scanner(System.in);
6+
7+
// Read a full line of input from stdin and save it to our variable, inputString.
8+
String inputString = scan.nextLine();
9+
10+
// Close the scanner object, because we've finished reading
11+
// all of the input from stdin needed for this challenge.
12+
scan.close();
13+
14+
// Print a string literal saying "Hello, World." to stdout.
15+
System.out.println("Hello, World.");
16+
System.out.println(inputString);
17+
18+
// ToDo: Write a line of code here that prints the contents of inputString to stdout.
19+
}
20+
}

30DaysOfCode/Day01.java

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import java.util.*;
2+
public class Day01 {
3+
4+
public static void main(String[] args) {
5+
int i = 4;
6+
double d = 4.0;
7+
String s = "HackerRank ";
8+
9+
Scanner scan = new Scanner(System.in);
10+
11+
/* Declare second integer, double, and String variables. */
12+
int j;
13+
double e;
14+
String t;
15+
16+
/* Read and save an integer, double, and String to your variables.*/
17+
// Note: If you have trouble reading the entire String, please go back and review the Tutorial closely.
18+
j = scan.nextInt();
19+
e = scan.nextDouble();
20+
scan.nextLine();
21+
t = scan.nextLine();
22+
23+
/* Print the sum of both integer variables on a new line. */
24+
System.out.println(i+j);
25+
26+
/* Print the sum of the double variables on a new line. */
27+
System.out.println(d+e);
28+
29+
/* Concatenate and print the String variables on a new line;
30+
the 's' variable above should be printed first. */
31+
System.out.println(s+t);
32+
33+
scan.close();
34+
}
35+
}
36+
37+
38+
39+

30DaysOfCode/Day02.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.*;
2+
3+
public class Day02 {
4+
5+
public static void main(String[] args) {
6+
Scanner scan = new Scanner(System.in);
7+
double mealCost = scan.nextDouble(); // original meal price
8+
int tipPercent = scan.nextInt(); // tip percentage
9+
int taxPercent = scan.nextInt(); // tax percentage
10+
scan.close();
11+
12+
// Calculate Tax and Tip:
13+
double tip = mealCost * tipPercent / 100;
14+
double tax = mealCost * taxPercent / 100;
15+
16+
// cast the result of the rounding operation to an int and save it as totalCost
17+
int totalCost = (int) Math.round(mealCost + tax + tip);
18+
19+
System.out.println("The total meal cost is " + totalCost + " dollars.");
20+
}
21+
}

30DaysOfCode/Day03.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import java.io.*;
2+
3+
public class Day03 {
4+
public static void main(String[] args) throws IOException {
5+
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
6+
7+
int N = Integer.parseInt(bufferedReader.readLine().trim());
8+
if(N % 2 == 1){
9+
System.out.println("Weird");
10+
}
11+
else if(2 <= N && N <= 5){
12+
System.out.println("Not Weird");
13+
}
14+
else if(6 <= N && N <= 20){
15+
System.out.println("Weird");
16+
}
17+
else {
18+
System.out.println("Not Weird");
19+
}
20+
21+
bufferedReader.close();
22+
}
23+
}

30DaysOfCode/Day04.java

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import java.util.*;
2+
3+
class Person {
4+
private int age;
5+
6+
public Person(int initialAge) {
7+
// Add some more code to run some checks on initialAge
8+
if(initialAge < 0){
9+
System.out.println("Age is not valid, setting age to 0.");
10+
age = 0;
11+
}
12+
else{
13+
age = initialAge;
14+
}
15+
}
16+
17+
public void amIOld() {
18+
// Write code determining if this person's age is old and print the correct statement:
19+
System.out.println(age < 13 ? "You are young." : age < 18 ? "You are a teenager." : "You are old.");
20+
}
21+
22+
public void yearPasses() {
23+
age++;
24+
}
25+
}
26+
27+
public class Day04 {
28+
public static void main(String[] args) {
29+
Scanner sc = new Scanner(System.in);
30+
int T = sc.nextInt();
31+
for (int i = 0; i < T; i++) {
32+
int age = sc.nextInt();
33+
Person p = new Person(age);
34+
p.amIOld();
35+
for (int j = 0; j < 3; j++) {
36+
p.yearPasses();
37+
}
38+
p.amIOld();
39+
System.out.println();
40+
}
41+
sc.close();
42+
}
43+
}

30DaysOfCode/Day05.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.io.*;
2+
3+
public class Day05 {
4+
public static void main(String[] args) throws IOException {
5+
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
6+
7+
int n = Integer.parseInt(bufferedReader.readLine().trim());
8+
for (int i = 1; i <= 10; i++){
9+
System.out.printf("%d x %d = %d\n", n, i, n*i);
10+
}
11+
12+
bufferedReader.close();
13+
}
14+
}

30DaysOfCode/Day06.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.*;
2+
3+
public class Day06 {
4+
5+
public static void main(String[] args) {
6+
Scanner in = new Scanner(System.in);
7+
int T = in.nextInt();
8+
in.nextLine();
9+
for (int t = 1; t <= T; t++) {
10+
String input = in.nextLine();
11+
String odd = new String();
12+
String even = new String();
13+
14+
for (int i = 0; i < input.length(); i++) {
15+
if (i % 2 == 0) {
16+
even += input.charAt(i);
17+
} else {
18+
odd += input.charAt(i);
19+
}
20+
}
21+
System.out.println(even + " " + odd);
22+
}
23+
in.close();
24+
}
25+
}

30DaysOfCode/Day07.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
5+
6+
public class Day07 {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
9+
10+
int n = Integer.parseInt(bufferedReader.readLine().trim());
11+
12+
String[] arrTemp = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
13+
14+
List<Integer> arr = new ArrayList<>();
15+
16+
for (int i = 0; i < n; i++) {
17+
int arrItem = Integer.parseInt(arrTemp[i]);
18+
arr.add(arrItem);
19+
}
20+
21+
for (int j = arr.size() - 1; j >= 0; j--){
22+
System.out.printf("%d ", arr.get(j));
23+
}
24+
25+
bufferedReader.close();
26+
}
27+
}

30DaysOfCode/Day08.java

Whitespace-only changes.

30DaysOfCode/Day09.java

Whitespace-only changes.

30DaysOfCode/Day10.java

Whitespace-only changes.

30DaysOfCode/Day11.java

Whitespace-only changes.

30DaysOfCode/Day12.java

Whitespace-only changes.

30DaysOfCode/Day13.java

Whitespace-only changes.

30DaysOfCode/Day14.java

Whitespace-only changes.

30DaysOfCode/Day15.java

Whitespace-only changes.

30DaysOfCode/Day16.java

Whitespace-only changes.

30DaysOfCode/Day17.java

Whitespace-only changes.

30DaysOfCode/Day18.java

Whitespace-only changes.

30DaysOfCode/Day19.java

Whitespace-only changes.

30DaysOfCode/Day20.java

Whitespace-only changes.

30DaysOfCode/Day21.java

Whitespace-only changes.

30DaysOfCode/Day22.java

Whitespace-only changes.

30DaysOfCode/Day23.java

Whitespace-only changes.

30DaysOfCode/Day24.java

Whitespace-only changes.

30DaysOfCode/Day25.java

Whitespace-only changes.

30DaysOfCode/Day26.java

Whitespace-only changes.

30DaysOfCode/Day27.java

Whitespace-only changes.

30DaysOfCode/Day28.java

Whitespace-only changes.

30DaysOfCode/Day29.java

Whitespace-only changes.

Java/Introduction/HackerRank_Loops1.java

-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
import java.io.*;
2-
import java.math.*;
3-
import java.security.*;
4-
import java.text.*;
5-
import java.util.*;
6-
import java.util.concurrent.*;
7-
import java.util.regex.*;
82

93

104

Java/Introduction/HackerRank_StdInStdOut2.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.util.Scanner;
22

3-
public class HackerRank_StdinStdout2 {
3+
public class HackerRank_StdInStdOut2 {
44

55
public static void main(String[] args) {
66
Scanner scan = new Scanner(System.in);
@@ -12,6 +12,7 @@ public static void main(String[] args) {
1212
System.out.println("String: " + s);
1313
System.out.println("Double: " + d);
1414
System.out.println("Int: " + i);
15-
15+
16+
scan.close();
1617
}
1718
}

0 commit comments

Comments
 (0)