Browse Source

Add Java to list

master
Matei-Alexandru Gardus 9 months ago
parent
commit
d1f93045dd
No known key found for this signature in database
2 changed files with 36 additions and 1 deletions
  1. 2
    1
      README.md
  2. 34
    0
      reverseNumber.java

+ 2
- 1
README.md View File

@@ -8,4 +8,5 @@ This is a Git repository of elementary algorithm programs for every language I k
8 8
 - C
9 9
 - C++
10 10
 - C#
11
-- Objective-C
11
+- Objective-C
12
+- Java

+ 34
- 0
reverseNumber.java View File

@@ -0,0 +1,34 @@
1
+import java.util.Scanner;
2
+
3
+/* "Reverse of a number"
4
+ *
5
+ * Ah, Java. The actual first *other* language I really learned.
6
+ *
7
+ * No programming language opened my horizons quite like Java did. I was a C nut before all the Java non-sense,
8
+ * and it showed. Monolithical algorithms, no functions, no logical compartmentalization (at least outside of C#),
9
+ * but with Java, everything changed. Java taught me the value of Object-Oriented Programming.
10
+ *
11
+ * Java was my first project language as well. I wrote an educational software, VianuEdu, in it, along with Go. It was a fun
12
+ * experience, along with one of my classroom colleagues. It was a time when I finally decided to really get serious
13
+ * when coding instead of screwing around with whatever I had in mind (which most commonly reduced itself to maths).
14
+ *
15
+ * Java also eased me into the GUI world with Swing. It still is pretty hard for me to code a GUI, but not as bad.
16
+ *
17
+ * This program reverses a number. Pretty self-explanatory.
18
+ */
19
+public class reverseNumber {
20
+
21
+    public static void main(String[] args) {
22
+        Scanner terminal = new Scanner(System.in);
23
+        System.out.println("Hey, guy! Gimme a number: ");
24
+        Integer number = terminal.nextInt();
25
+        terminal.close();
26
+        Integer reversedNumber = 0;
27
+        while (number > 0) {
28
+            reversedNumber = reversedNumber * 10 + (number % 10);
29
+            number /= 10;
30
+        }
31
+        System.out.println("Reversed number: " + reversedNumber);
32
+    }
33
+
34
+}

Loading…
Cancel
Save