wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Ipcalculator Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Ipcalculator Help" Watch "Ipcalculator Help" New topic
Author

Ipcalculator Help

Mezan Shareef
Ranch Hand

Joined: Apr 01, 2010
Posts: 40
Hi all, i am new to java and also this forums,could any one help me solve my doubts, i am trying to learn java programming through examples.

Task: Develop a program that parses an ip address and subnet mask and prints out the associated network id and host id.

Doubt 1: Please tell me algorithm for this, i am lot of confused.
Doubt 2: How can i store an Ip address in a variable.? what datatype i should use. I am not sure if i enter a string would it be recognized as an ip address or just as a series of charecters...

May be i am wrong. can any one shed some light on my head.
adil qureshi
Ranch Hand

Joined: Jul 11, 2008
Posts: 48
You can store your ip address in a string but yes please see that what is the required output data type because after you pic the values from array .
Can you use split function .You can easily split using split() function in java (don't forget to convert your ip address to string first ) .Then you will get an array in return of which values can be easily identified.
Also if split is not an option then you can manually write the code to split a string .
If this doesn't clears your doubt please enter the input and output values here.

SCJP 1.5,SCWCD 1.5
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37958
    
  22
Welcome to the Ranch

IPs have a set format which you should be able to identify easily with a regular expression.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41092
    
  44
Since you seem unsure of how, exactly, an IP address looks like, I'd start by reading up on IP version 4 addresses at http://en.wikipedia.org/wiki/IP_address. Once you've got that mastered, you can move on to include IP version 6 addresses.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ipcalculator Help
 
Similar Threads
How to get Mac Id of my client machine
how to get IP address in linux
Doubt in this()
Basic Doubt
Doubt