Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Focus on Basic file operations, exception handling.
Save a copy of the file module6data.txt (Below)
Write a program that will
- Open the file module6data.txt
- Create a second file named processed. txt
- Read the numbers from the first file one at a time. For each number write into second file, if possible, its
- Square
- Square root
iii. Reciprocal (1/number)use a math module function for the square root. use exception handling to trap possible errors.
- Report the number of items in the original file and the number that were successfully stored in the second file.
- Report the number of each type of error: ValueError, ZeroDivisionError, TypeError
26
O
76
-91
85
-44
85
-95
-34
83
-64
-76
-41
89
0
83
-99
-69
8
-79
0
-32
-49
-89
85
79
-28
56
19
-93
-21
-23
82
51
-80
l
62
-78
-8
71
28
-73
0
-45
-73
28
-5
O
-70
63
-36
-72
0
-76
-24
-59
0
-54
83
35
-3
88
-14
29
-35
17
27
-61
-42
49
83
38
79
-80
33
8
41
96
-94
46
71
8
76
-63
-36
93
-82
-68
-20
69
-57
-84
-29
-17
77
36
-89
-94
62
10
-69
-43
- Use meaningful variable names. Single letter variable names are forbidden except as counters in loops.
- Use blank lines to separate major parts of a program or function.
- Use spaces around all operators. For example, write x = y + 5, NOT x=y+5
- Use named constants, not magic numbers.
- Organize your python program file. Your file should have, in this order
- a full header comment, as specified in the guidelines
- any named constants used by the program,
- the definition of the main() function,
- all functions other than main(),
- the call to main()at the very bottom of the file.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
Knowledge Booster
Similar questions
- In the event of an exception being thrown, how can the default error message be displayed?arrow_forwardC# program in Visual Studio Code. The main application class must meet the following requirements Ask the user to enter their age If the age is between 1 and 100 (inclusive) print a message stating the age the user entered exit the program If the age is less than 1 or greater than 100 generate an ArgumentOutOfRangeException print the exception information print an error message If the value is not an integer handle the FormatException print the exception information print an error message Continue asking the user to enter their age until a valid age is enteredarrow_forwardWhy should an exception be thrown throughout the process?arrow_forward
- T/F 6) Exception is a component of the class library of both java.lang and java.io, but IOException is exclusive to java.ioarrow_forwardPlease give the names of the various approaches of managing exceptions that are available.arrow_forward4. Read from File Create a program that reads the values in the temperature data file created in the previous program. The program will display each temperature value in the file and calculate and display the average temperature. Be sure your program handles exceptions.arrow_forward
- PARTICIPATION ACTIVITY Arrange the following lines to make a program that determines when the number of people in a restaurant equals or exceeds 10 occupants. The program continually gets the number of people entering or leaving the restaurant. Ex: 2 means two people entered, and -3 means three people left. After each input, the program outputs the number of people in the restaurant. Once the number of people in the restaurant equals or exceeds 10, the program exits. If an Input MismatchException exception occurs, the program should get and discard a single string from input. Ex: The input "2 abc 8" should result in 10 occupants. Not all lines are used in the solution. How to use this tool ✓ Unused totalNumPeople += scnr.nextInt (); while (totalNumPeople < maxNumPeople) { } } 11.1.5: Handling input exceptions: restaurant max occupancy tracker. catch { try { catch (InputMismatchException e) { scnr .nextLine(); scnr.next(); System.out.println("Error"); } System.out.println("Occupancy:…arrow_forwardPlease give the names of the various approaches of managing exceptions that are available.arrow_forwardDescribe how to handle exceptions with in a program.arrow_forward
- Focus on Basic file operations, exception handlingCreate and save a file of the number below as module6data.txt: 26O76-9185-4485-95-3483-64-76-4189083-99-698-790-32-49-898579-285619-93-21-238251-80l62-78-87128-730-45-7328-5O-7063-36-720-76-24-590-548335-388-1429-351727-61-4249833879-803384196-944671876-63-3693-82-68-2069-57-84-29-177736-89-946210-69-43Write a program in python that will a. Open the file module6data.txtb. Create a second file named processed.txtc. Read the numbers from the first file one at a time. For each number write into thesecond file, if possible, itsi. square ii. square root.iii. reciprocal (1/number) each on a separate line.• Use a math module function for the square root.• Use exception handling to trap possible errors. Error messages should be reported to the screen.d. Report the number of items in the original file and the number that were successfully stored in the second file.e. Report the number (count) of each type of error: ValueError, ZeroDivisionError,…arrow_forwardChapter 6 complete the following Programming Exercises. #3 Line Numbers #6 Average of Numbers #7 Random Number File Writer #9 Exception Handling (this one is just a revised version of #6 above) Note: You will need to create a few text files to test your code. Using notepad or any other text editor (not MS word!) to create some text files that contain sample data. Save your files with the extension ".txt". Be sure to submit your sample text files with your lab.arrow_forwardFocus on Basic file operations, exception handlingSave a copy of the file module6data.txt (attached to the assignment)Write a program in python that will a. Open the file module6data.txtb. Create a second file named processed.txtc. Read the numbers from the first file one at a time. For each number write into thesecond file, if possible, itsi. square ii. square root.iii. reciprocal (1/number) each on a separate line.• Use a math module function for the square root.• Use exception handling to trap possible errors. Error messages should be reported to the screen.d. Report the number of items in the original file and the number that were successfully stored in the second file.e. Report the number (count) of each type of error: ValueError, ZeroDivisionError, TypeErrorarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY