Browse Source

Add Java to list

master
parent
commit
d1f93045dd
Signed by: StormFireFox1 <matei@gardus.eu> GPG Key ID: F3D2B830AB9B94AA
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
- C
- C++
- C#
- Objective-C
- Objective-C
- Java

+ 34
- 0
reverseNumber.java View File

@@ -0,0 +1,34 @@
import java.util.Scanner;

/* "Reverse of a number"
*
* Ah, Java. The actual first *other* language I really learned.
*
* No programming language opened my horizons quite like Java did. I was a C nut before all the Java non-sense,
* and it showed. Monolithical algorithms, no functions, no logical compartmentalization (at least outside of C#),
* but with Java, everything changed. Java taught me the value of Object-Oriented Programming.
*
* Java was my first project language as well. I wrote an educational software, VianuEdu, in it, along with Go. It was a fun
* experience, along with one of my classroom colleagues. It was a time when I finally decided to really get serious
* when coding instead of screwing around with whatever I had in mind (which most commonly reduced itself to maths).
*
* 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.
*
* This program reverses a number. Pretty self-explanatory.
*/
public class reverseNumber {

public static void main(String[] args) {
Scanner terminal = new Scanner(System.in);
System.out.println("Hey, guy! Gimme a number: ");
Integer number = terminal.nextInt();
terminal.close();
Integer reversedNumber = 0;
while (number > 0) {
reversedNumber = reversedNumber * 10 + (number % 10);
number /= 10;
}
System.out.println("Reversed number: " + reversedNumber);
}

}

Loading…
Cancel
Save