Write a program that reads a device name host name or domain

Write a program that reads a device name (host name or domain name) from the keyboard and then prints the device network address on the screen like the below example:

Device name: www.something.edu

Device IP address: 195.223.156.19

Solution

Answer:

import java.net.*;
import java.io.*;
public class Devicenametoipaddress
{
   public static void main(String args[]) throws Exception
   {
       System.out.println(\"Enter host name or device name :\");
       String input=new DataInputStream(System.in).readLine();

       InetAddress value =InetAddress.getByName(input);

       System.out.println(\"Device IP address :\"+value);
   }
}

Write a program that reads a device name (host name or domain name) from the keyboard and then prints the device network address on the screen like the below ex

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site