Results 1 to 7 of 7
- 02-18-2011, 03:13 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
- 02-18-2011, 03:31 AM #2
Mod and divide. Some food for thought.
Java Code:System.out.println(9876 / 1000); System.out.println(9876 % 100);
- 02-18-2011, 04:09 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
I must be able to call the individual numbers by the single digit in a tester class
- 02-18-2011, 04:18 AM #4
and???
Did you look at my code? It wasn't the answer to your problem but merely to prompt you to think about it. Did you try mod and divide with other numbers such as 10,000 1,000,000 100,000 etc and see if any of them might help you.
- 02-18-2011, 04:54 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
yes I have figured out how to extract the individual numbers, thank you. I do not understand the concept of returning a long integer broken into individual number to a single method. Would I use a for or if statement?
- 02-18-2011, 04:57 AM #6
I'd use a while loop.
Java Code:while some value is greater than 0 { mod it divide it }
- 02-18-2011, 03:53 PM #7
Member
- Join Date
- Feb 2011
- Posts
- 4
- Rep Power
- 0
public class DigitExtractor {
private static int intNumber;
public DigitExtractor(int anInteger)
{
intNumber = anInteger;
String number = String.valueOf(intNumber);
char charNumber = number.charAt(4);
int x = number.charAt(3);
int x1 = number.charAt(2);
int x2 = number.charAt(1);
int x3 = number.charAt(0);
}
public static String nextDigit()
{
I dont understand if I return one number is only gives me that number. Even if I use the while Loop it will not let me return more then one number. I am complelty stuck
Similar Threads
-
Letter L or l to long integer?
By Jagdeesh123 in forum New To JavaReplies: 1Last Post: 12-09-2010, 08:05 AM -
Please Review My Code (Long Integer Addition)
By Saradus in forum New To JavaReplies: 12Last Post: 07-05-2009, 01:01 PM -
extracting bits from big numbers
By ankitmcgill in forum New To JavaReplies: 6Last Post: 05-05-2009, 04:36 AM -
Calculating Individual Numbers
By TheKnight in forum New To JavaReplies: 2Last Post: 01-30-2009, 12:51 AM -
Calculate sum of long integer!
By Julingo in forum New To JavaReplies: 2Last Post: 09-09-2008, 11:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks