Invernes
Process Workflow Enhancer
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 2
1000 XP
Program code requests a user to enter a number then outputs the result as the number reversed. Say, the original number is 1234, the output will be 4321.
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
- Using eclipse
- import
java.util.Scanner
;
- public
class
ReverseNumber {
- public
static
void
main(
String
[
]
args)
{
- System
.out
.println
(
"Please enter a number: "
)
;
- int
number =
new
Scanner(
System
.in
)
.nextInt
(
)
;
- int
reversedNumber, i;
- reversedNumber =
0
;
- i =
0
;
- while
(
number >
0
)
{
- /*this will get the remainder of the number which will be
- *the rightmost digit
- */
- i =
number %
10
;
- //this creates the reversed number
- reversedNumber =
reversedNumber *
10
+
i;
- //The result will be stored as an integer value
- number =
number/
10
;
- }
- System
.out
.println
(
"The number reversed is: +reversedNumber);
- }
- }
- Using a text editor & command prompt
- import java.io.*;
- class ReverseNumber{
- public static void main(String args[]) {
- try {
- BufferedReader s =
- new BufferedReader(new InputStreamReader(System.in));
- int number, reversednumber, i;
- System.out.print("
Enter the number to be reversed:
");
- number = Integer.parseInt(s.readLine());
- i = 0;
- reversednumber = 0;
- while(number > 0){
- i = number % 10;
- reversednumber = reversednumber * 10 + i;
- number = number/10;
- }
- System.out.print("
The number reversed:
" + reversednumber);
- }
- catch(IOException e){}
- }
- }
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
You must upgrade your account or reply in the thread to view the hidden content.