
In Java
Every computer on the Internet has a unique identifying number, called an Internet
protocol (IP) address. To contact a computer on the Internet, you send a message to
the computer’s IP address. Here are some typical IP addresses:
216.27.6.136
224.0.118.62
There are different formats for displaying IP addresses, but the most common
format is the dotted decimal format. The above two IP addresses use the dotteddecimal format. It’s called “dotted” because dots are used to split up the big IP
address number into four smaller numbers. It’s called “decimal” because decimal
numbers are used (as opposed to binary) for the four smaller numbers.
Each of the four smaller numbers is called an octet because each number represents
eight bits (oct means eight). For example, the 216 octet represents 11011000 and
the 27 octet represents 00011011.
Implement an IpAddress class that stores an IP address as a dotted-decimal string
and as four octet ints. You must implement all of the following:
Instance variables:
1-dottedDecimal – a dotted-decimal string. Example value: "216.27.6.136"
2-firstOctet, secondOctet, thirdOctet, fourthOctet – four int variables that
store the octets for an IP address
Constructor:
This constructor receives one parameter, a dotted-decimal string. You may assume
that the parameter’s value is valid (i.e., no error checking required). The constructor
initializes the instance variables with appropriate values. There are many ways to
solve the problem of extracting octets from the given dotted-decimal string. We
recommend that you use String methods to extract the individual octets as strings,
and then use parseInt method calls to convert the octet strings to ints.
getDottedDecimal method:
This is a standard accessor method that simply returns the dottedDecimal instance
variable’s value.
getOctet method:
This method receives the position of one of the octets (1, 2, 3, or 4) and returns
the octet that’s at that position.
Provide a driver class that tests your IpAddress class. Your driver class should
contain this main method:
public static void main(String[] args)
{
IpAddress ip = new IpAddress("216.27.6.136");
System.out.println(ip.getDottedDecimal());
System.out.println(ip.getOctet(4));
System.out.println(ip.getOctet(1));
System.out.println(ip.getOctet(3));
System.out.println(ip.getOctet(2));
} // end main
Using the above main method, your program should generate the following output.
Sample output:
216.27.6.136
136
216
6
27
IPAddress Class:
public class IpAddress
{
// IP address using dotted-decimal format
// IP address's four octets
//***********************************************************
// This constructor initializes the instance variables with the given dottedDecimal
string.
public IpAddress(String dottedDecimal)
{
} // end constructor
//***********************************************************
public String getDottedDecimal()
{
} // end getOctet
//***********************************************************
// This method returns the octet at the given position.
public int getOctet(int octetPosition)
{
} // end getOctet
} // end class IpAddress

Step by stepSolved in 3 steps

- PHP language.arrow_forwardThere should be two files or codes for this solution: the distance code and the second code fallingdistancearrow_forwardProgram #3: Gradebook Report (60 pts) • Create a Python program named Exam-3.py • Create three dictionaries: 1loyd, alice, and tyler. • Give each dictionary the keys "name", "homework", "quizzes", and "tests". Now copy this code: lloyd = { "name": "Lloyd", "homework": [90.e,97.e,75.e,92.0], "quizzes": [88.0,40.0,94.0], "tests": [75.0,90.0] alice = { "name": "Alice", "homework": [100.e, 92.0, 98.e, 100.0], "quizzes": [82.0, 83.0, 91.0], "tests": [89.e, 97.e] tyler = { "name": "Tyler", "homework": [e.e, 87.e, 75.e, 22.e], "quizzes": [0.0, 75.0, 78.0], "tests": [100.0, 100.0] Add this code to create a list to include the above dictionaries as items in the list called Student: students-[1loyd, alice, tyler] Add this code to display each student's name and the values of their grades for each category: for student in students: print(student["name"]) print (student["homework" ]) print (student "quizzes"]) print (student["tests"])arrow_forward
- Write a program that converts U.S. Dollar Amounts to different Cryptocurrencies by multiplying US Dollar amounts times conversion factors stored in named constants. Ask the user to enter the amount of money in U.S. Currency, then display the output of the conversions to the different cryptocurrencies listed below. The following conversion rates must be stored as named constants: 1 US Dollar = 0.00002306 Bitcoin (BTC)1 1 US Dollar = 0.01122814 Ethereum Classic (ETC)1 1 US Dollar = 2.07961078 Dogecoin (DOGE)1 1 US Dollar = 0.48910811 Cardano (ADA)1 Format your currency amounts in fixed point notation with two decimal places of precision, and be sure that the decimal point is always displayed.arrow_forwardNEED HELP WITH PYTHON CODE. ALSO, PLEASE PROVIDE DETAILS SEPARATELY ON HOW AND WHAT DID U USE TO GET UR CODE DONE.arrow_forwardWrite a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the last name. Hint: Use the to_string() function to convert numerical data to a string.arrow_forward
- ey Section 3.10 - CS 10 learn.zybooks.com My library > CS 1010: Algorithmic Problem Solving home> E zyBooks catalog ? Help Tooks 3.10: LAB: Phone number breakdown 3.10 LAB: Phone number breakdown Given an integer representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-1212. Ex: If the input is: 8005551212 the output is: (800) 555-1212 Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2 digits of 572 is gotten by 572 % 100, which is 72. Hint: Use // to shift right by the desired amount. Ex: Shifting 572 right by 2 digits is done by 572 // 100, which yields 5. (Recall integer division discards the fraction). For simplicity, assume any part starts witha non-zero digit. So 0119998888 is not allowed. 318650 2047284gda LAB 3.10.1: LAB: Phone number breakdown 0/ 10 АCTIVITY main.py Load default template 1 phone_number - int(input ()) P Type here to search (? 85°F *: 10 + prt sc delete %23 %24 4 & * 3. 6. 7 8 9. backspace…arrow_forwardConvert the decimal (base 10) number 40 to a binary (base 2) number that has only the digits '0' and '1'. Binary number: (For example, the decimal number 16 is the same as the binary number 10000; the decimal number 13 is the same as the binary number 1101.)arrow_forwardWrite code that prints a random number of lines between 2 and 10 lines inclusive, where each line contains a random number of 'x' characters between 5 and 20 inclusive. For example: xxxxxxx xxxxxxxxxxxxxxxxxx xxxxxxxxxxxx xxxxxx xxxxxxxxxxx xxxxxxxxxxxxxxxxarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





