You will need to validate that the IP address is in the correct format. Check for...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You will need to validate that the IP address is in the correct format. Check for these validation conditions IN THIS ORDER: Split what the user enters across the periods and see if there are 4 separate parts. If there are not, display an appropriate error message and continue in the loop. Do not check on other error conditions. Check whether each part of the IP address is a number. If any part is not a number, display an appropriate error message and continue in the loop without checking other error conditions. Check whether each number in the IP address is between 0 and 255 inclusive. If any number is not, display an appropriate error message and continue in the loop without checking other error conditions. If the IP address entered was valid, then change the periods to colons and display the newly formatted IP address. For example, if the IP address was: 192.168.0.1 ...the program should display: 192:168:0:1 The program will continue asking the user for IP addresses until they enter a q or Q to exit the program. Here's pseudocode to help you solve this problem: #Ask the user to input an IP address or 'Q' to quit #while the user has not entered 'Q' or 'q' to quit #split the user input at each period and store the parts in a list # if there are not 4 parts in the list # display an error message # else #set error flag to False #for each part in the list # if the part is not a number or if it is not between 0 and 255 #display an error message #set error flag to True #break the loop #if no error has been displayed (i.e., error flag is False) # replace each period in the user input with a colon #display the new formatted IP address # ask the user to input an IP address or 'Q' to quit You may want to consider copying the above pseudocode into your Python file and use it as comments that can also guide you as you write this program. Sample output: Please enter an IP address or 'Q' to quit: 122.44.33 Error: An IP address should consist of 4 parts separated by periods. Please enter an IP address or 'Q' quit: 122.44.33.x Error with x: Each part of the IP address should be a number between 0 and 255. Please enter an IP address or 'Q' to quit: 122.444.33.x Error with 444: Each part of the IP address should be a number between 0 and 255. Please enter an IP address or 'Q' to quit: 122.44.33.89 Reformatted IP address: 122:44:33:89 Please enter an IP address or 'Q' to quit: q You will need to validate that the IP address is in the correct format. Check for these validation conditions IN THIS ORDER: Split what the user enters across the periods and see if there are 4 separate parts. If there are not, display an appropriate error message and continue in the loop. Do not check on other error conditions. Check whether each part of the IP address is a number. If any part is not a number, display an appropriate error message and continue in the loop without checking other error conditions. Check whether each number in the IP address is between 0 and 255 inclusive. If any number is not, display an appropriate error message and continue in the loop without checking other error conditions. If the IP address entered was valid, then change the periods to colons and display the newly formatted IP address. For example, if the IP address was: 192.168.0.1 ...the program should display: 192:168:0:1 The program will continue asking the user for IP addresses until they enter a q or Q to exit the program. Here's pseudocode to help you solve this problem: #Ask the user to input an IP address or 'Q' to quit #while the user has not entered 'Q' or 'q' to quit #split the user input at each period and store the parts in a list # if there are not 4 parts in the list # display an error message # else #set error flag to False #for each part in the list # if the part is not a number or if it is not between 0 and 255 #display an error message #set error flag to True #break the loop #if no error has been displayed (i.e., error flag is False) # replace each period in the user input with a colon #display the new formatted IP address # ask the user to input an IP address or 'Q' to quit You may want to consider copying the above pseudocode into your Python file and use it as comments that can also guide you as you write this program. Sample output: Please enter an IP address or 'Q' to quit: 122.44.33 Error: An IP address should consist of 4 parts separated by periods. Please enter an IP address or 'Q' quit: 122.44.33.x Error with x: Each part of the IP address should be a number between 0 and 255. Please enter an IP address or 'Q' to quit: 122.444.33.x Error with 444: Each part of the IP address should be a number between 0 and 255. Please enter an IP address or 'Q' to quit: 122.44.33.89 Reformatted IP address: 122:44:33:89 Please enter an IP address or 'Q' to quit: q
Expert Answer:
Related Book For
Principles Of Information Security
ISBN: 9780357506431
7th Edition
Authors: Michael E. Whitman, Herbert J. Mattord
Posted Date:
Students also viewed these programming questions
-
Gary runs a metal fabrication business in inner city Hobart and has a long-term (12 years) lease of his factory. He has won a tender to supply metal frames to be used in the construction of a high...
-
Write statement which best describes a characteristic of the master budget?
-
You will design and implement your own data class. The class will store data that has been read as user input from the keyboard (see Getting Input below), and provide necessary operations. As the...
-
Reference frame S is moving along the x axis at 0.6c relative to frame S. A particle that is originally at x = 10 m at t 1 = 0 is suddenly accelerated and then moves at a constant speed of c/3 in...
-
Combine stagnation flow, Fig. 8.14b, with a source at the origin: f(z)=Az2+mln(z) Plot the streamlines for m = AL2, where L is a length scale. Interpret. SP PM
-
Use a Karnaugh map to find a minimal-sum-of products representation for (a) f(w, x, y, z) = m(0, 2, 3, 6, 7, 14, 15) (b) g(v, w, x, y, z) = M(1, 2, 4, 6, 9, 10, 11, 14, 17, 18, 19,20, 22, 25,26,...
-
A hydraulic press has a ram diameter of 250 mm and a plunger diameter of 30 mm. For a force of 40 N applied on the plunger, find the force exerted on the object by the hydraulic press.
-
The unadjusted and adjusted trial balances for Editorial Services Co. on March 31, 2014, are shown below. Journalize the five entries that adjusted the accounts at March 31, 2014. None of the...
-
4. Given the following code: Mystery (n) { if (n == 1) return; else { for j = 1 to n*n { print (j); } Mystery (n/2) Mystery (n/2) Mystery (n/2) Mystery (n/2) } } Mystery (n/2) a) What is the...
-
The carrying amount of ABZ Inc. equity at January 1, 2018 was: Equity CU 1,200,000 Share Capital compromising 120,000 shares of CU 10 par value each Share premium 4,800,000 Share Option Reserve...
-
Some mangoes are purchased at the rate of 8 mangoes/Rs and some more mangoes at the rate of 6 mangoes/Rs, investment being equal in both the cases. Now, the whole quantity is sold at the rate of 3.5...
-
Teresa is a 32-year-old woman in your practice who frequently misses her appointments and at other times shows up without an appointment, often in crisis. She currently uses alcohol and tobacco, and...
-
You are risk averse, and youre utility is given by U(W) = W (i.e W 0.5) ), where W is your wealth, which is currently $200,00. You are considering buying car insurance. a. If there is a 2% chance of...
-
Weaver Corporation had the following stock issued and outstanding at January 1, Year 1: 1. 73,000 shares of $4 par common stock. 2. 7,000 shares of $90 par, 6 percent, noncumulative preferred stock....
-
The Manning Company has financial statements as shown next, which are representative of the company's historical average. The firm is expecting a 30 percent increase in sales next year, and...
-
A Darrieous rotor has an area of 1500 m 2 and operates at the optimal tip speed ratio. What is its power output in a wind with a velocity of 20 m/s?
-
The following are selected 2020 transactions of Blossom Corporation. Sept. 1 Oct. 1 Oct. 1 (a) Purchased inventory from Encino Company on account for $58,600. Blossom records purchases gross and uses...
-
The Ferris wheel in the figure has a radius of 68 feet. The clearance between the wheel and the ground is 14 feet. The rectangular coordinate system shown has its origin on the ground directly below...
-
I. Justify the reasons why an organization turns to a SIEM as a central location to empower a security operations center (SOC) to react and identify various events against their information systems....
-
What type of firewall examines every incoming packet header and can selectively filter packets based on header information, such as destination address, source address, packet type, and other key...
-
Explain that most IT and information security organizations have their own codes of ethics, and what is contained in them may vary from one another.
-
Companies are facing a great amount of change in every facet of their operations today. To remain competitive, companies must keep abreast of current developments in several areas. You recently got...
-
For each of the situations listed, identify the primary standard from the IMA Statement of Ethical Professional Practice that is violated (competence, confidentiality, integrity, or credibility.)...
-
Sustainability involves more than just the impact of actions on the environment. The triple bottom line recognizes that a company has to measure its impact on its triple bottom line for its long-term...
Study smarter with the SolutionInn App