Question:
what is the java code for reversing number inputs?
Edrew c
2008-01-23 00:15:54 UTC
what is the java code for reversing number inputs?
numbers limited from 0-999 number value
sample

input number: 321
output: 123

input number: 102
output: 201

input number: 101
output: 101

some additional samples
input number: 100
output: 1

input number: 10
output: 1
Nine answers:
angel04
2008-01-23 00:34:57 UTC
/*

This program reads up to 100 non-zero numbers from the user

and then outputs them in reverse order.

*/



public class ReverseInputNumbers {



public static void main(String[] args) {



int[] numbers; // An array for storing the input values.

int numCt; // The number of numbers saved in the array.

int num; // One of the numbers input by the user.



numbers = new int[100]; // Space for 100 ints.

numCt = 0; // No numbers have been saved yet.



TextIO.putln("Enter up to 100 positive integers; enter 0 to end.");



while (true) { // Get the numbers and put them in the array.

TextIO.put("? ");

num = TextIO.getlnInt();

if (num <= 0)

break;

numbers[numCt] = num;

numCt++;

}



TextIO.putln("\nYour numbers in reverse order are:\n");



for (int i = numCt - 1; i >= 0; i--) {

TextIO.putln( numbers[i] );

}



} // end main();



} // end class ReverseInputNumbers
?
2017-01-20 09:36:22 UTC
1
dawebdev
2008-01-23 01:06:04 UTC
Hi there,

Its pretty mathematical. I will prefer to try my best to describe the logic behind. Coding is never an issue :)



Firstly you are required to reverse the digits in a number and not to reverse their indexs. So the concept of arrays can be implemented.

You are required to pick each number one by one from right to left and do concatenation to a result string in left to right order.



Case: number=321

output should be = 123

take 1 then 2 then 3 from the input number 321.



logic is:

take MOD of 321 by 10, this will give the remainder i.e; 1

divide 321 by 10, this will give you the answer in decimal format, extract integer only. So 321/10 = 32.1 i.e: 32

By now you have mod_value = 1

and remaing_input = 32



make this is a whiel loop untill the remaing_input value reaches to 0. Concatenate the results on every iteration.



I hope you have understood the logic and concept.
anonymous
2016-04-24 06:14:10 UTC
Reverse Phone Number Look Up Services
anonymous
2015-08-06 20:34:14 UTC
This Site Might Help You.



RE:

what is the java code for reversing number inputs?

what is the java code for reversing number inputs?

numbers limited from 0-999 number value

sample



input number: 321

output: 123



input number: 102

output: 201



input number: 101

output: 101



some additional samples

input number: 100

output: 1



input number: 10

output: 1
anonymous
2015-02-15 21:49:48 UTC
reverse phone number search compiles hundreds of millions of phone book records to help locate the owner's name, location, time zone, email and other public information.



Use a reverse phone lookup to:

Get the identity of an unknown caller.

Identify an area code.

Recall the name of a person whose number you wrote down.

Identify an unfamiliar phone number that shows up on your bill.

https://tr.im/Nz9Ok
anonymous
2015-02-15 01:59:43 UTC
reverse phone number search compiles hundreds of millions of phone book records to help locate the owner's name, location, time zone, email and other public information.



Use a reverse phone lookup to:

Get the identity of an unknown caller.

Identify an area code.

Recall the name of a person whose number you wrote down.

Identify an unfamiliar phone number that shows up on your bill.

https://tr.im/DNMdD
anonymous
2008-01-23 01:26:12 UTC
I don't know java. I am a flash programmer so I can tell u only logic



if u divide any number from 10 then it's output will be in reversing order. check it out
answerseeker
2008-01-23 00:22:41 UTC
I'm pretty sure you can simply use: reverse(int i)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...