User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,936 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,762 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 3862 | Replies: 7
Closed Thread
Join Date: Oct 2004
Posts: 1
Reputation: kumar25 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kumar25 kumar25 is offline Offline
Newbie Poster

need help to create a java program

  #1  
Oct 14th, 2004
hi all,
i am a beginner in java programming.Could anyone please provide source code for the following program.
A program that reads a integer and breaks it into a sequence of individual digits in reverse order.TQ.
AddThis Social Bookmark Button
 
Join Date: Aug 2004
Location: Hanover
Posts: 152
Reputation: cosi is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 1
cosi's Avatar
cosi cosi is offline Offline
Junior Poster

Re: need help to create a java program

  #2  
Oct 14th, 2004
Hi Kumar,

Attempt to do your homework yourself, and then we can help you along the way. We do not do homework for you here.


Ed

Originally Posted by kumar25
hi all,
i am a beginner in java programming.Could anyone please provide source code for the following program.
A program that reads a integer and breaks it into a sequence of individual digits in reverse order.TQ.
In a world without walls or fences,
What use are Windows and Gates.
 
Join Date: Aug 2004
Location: North Carolina
Posts: 25
Reputation: Banderson is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Banderson's Avatar
Banderson Banderson is offline Offline
Light Poster

Re: need help to create a java program

  #3  
Oct 14th, 2004
Oh my, how many times must this be repeated?
 
Join Date: Jul 2003
Location: Bamberg, Germany
Posts: 117
Reputation: Iron_Cross is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 2
Iron_Cross's Avatar
Iron_Cross Iron_Cross is offline Offline
Junior Poster

Re: need help to create a java program

  #4  
Oct 14th, 2004
If you're having trouble try reading in the integers into an array. Or you could turn the string into an array with the CopyTo() method or ToArray() methods.
elitehackers.info
Today's Penny-Arcade!
Pain is weakness leaving the body!
 
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: need help to create a java program

  #5  
Oct 14th, 2004
Here is how to reverse an inputed string, just apply it all to Int and you should have your program:

class ReverseString
public class ReverseString
{
 public String reverse(String arg)
 {
	String tmp = null;
	if (arg.length() == 1)
	{
		return arg;
	}
	
	else
	{
		

		//extract the last char
		String lastChar = arg.substring(arg.length()-1,arg.length());
		
		
		//extract the remaining chars
		String remainingString = arg.substring(0, arg.length() -1);

		tmp = lastChar + reverse(remainingString);
		return tmp;
		
		
	}
  }
}

class TestReverse
import java.io.*;


public class TestReverse
{
	public static void main(String[] args) throws IOException
 	{
		System.out.println("Enter a line to be reversed");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inData;
		inData = br.readLine();
		ReverseString rs = new ReverseString();
		System.out.println("Reversed: " + rs.reverse(inData));	
	}
}
 
Join Date: Jun 2004
Location: H4x0rville
Posts: 2,105
Reputation: server_crash is on a distinguished road 
Rep Power: 9
Solved Threads: 18
server_crash's Avatar
server_crash server_crash is offline Offline
Postaholic

Re: need help to create a java program

  #6  
Oct 14th, 2004
You can also get it to print the letters individually if you put the println() statement in the first class.
 
Join Date: Sep 2004
Posts: 35
Reputation: tigerxx is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
tigerxx tigerxx is offline Offline
Light Poster

Re: need help to create a java program

  #7  
Oct 14th, 2004
Originally Posted by server_crash
Here is how to reverse an inputed string, just apply it all to Int and you should have your program:

class ReverseString
public class ReverseString
{
 public String reverse(String arg)
 {
	String tmp = null;
	if (arg.length() == 1)
	{
		return arg;
	}
	
	else
	{
		

		//extract the last char
		String lastChar = arg.substring(arg.length()-1,arg.length());
		
		
		//extract the remaining chars
		String remainingString = arg.substring(0, arg.length() -1);

		tmp = lastChar + reverse(remainingString);
		return tmp;
		
		
	}
  }
}

class TestReverse
import java.io.*;


public class TestReverse
{
	public static void main(String[] args) throws IOException
 	{
		System.out.println("Enter a line to be reversed");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String inData;
		inData = br.readLine();
		ReverseString rs = new ReverseString();
		System.out.println("Reversed: " + rs.reverse(inData));	
	}
}


plz don't do like this..................
they should do the hw themselvs
 
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 101
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: need help to create a java program

  #8  
Oct 15th, 2004
Originally Posted by tigerxx
plz don't do like this..................
they should do the hw themselvs

VERY true.

We're here not to help people cheat, but to help people learn.
Alex Cavnar, aka alc6379
 
Closed Thread

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 8:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC