rpose: To practice write a list of Pecoras toa tabular text file egree of Difficulty: Moderate. n this question, your program will define a function named fnWriteState(), with two input parameter · A list of records (the list of state of all days) · A string of a path name of the output file nd there is no return values of this function. n this function, your program will write the list of state to a tabular file. It is notable that the output hould locate in the same folder of the a6.py file. In the state output file, the first line is names of the tir , I and R. And lines from the second to the last line of the output file contain every day's state of S, I a in the list of state, and also with the item of time (indicates the index of the day). Each record in the f state will be written in one line. And the items of each line will be separated by commas. Basically, ormat of the state output file is the same as the state input file. But in the state output file, both the st f being read in from the state input file, and calculated by the simulation function in Q4 are all include he first few lines of the state output file look like this: ime(day),S,I,R , 9999, 1,0 , 9998.840016, 1.0885554285714287, 0.07142857142857142 9998.66586733474, 1.1849501346490998, 0.1491825306122449

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.3: Random File Access
Problem 6E
icon
Related questions
Question
100%
Purpose: To practice write a list of records to a tabular text file
Degree of Difficulty: Moderate.
In this question, your program will define a function named fnWriteState(), with two input parameters:
· A list of records (the list of state of all days)
· A string of a path name of the output file
And there is no return values of this function.
In this function, your program will write the list of state to a tabular file. It is notable that the output file
should locate in the same folder of the a6.py file. In the state output file, the first line is names of the time,
S, I and R. And lines from the second to the last line of the output file contain every day's state of S, I and
R in the list of state, and also with the item of time (indicates the index of the day). Each record in the list
of state will be written in one line. And the items of each line will be separated by commas. Basically, the
format of the state output file is the same as the state input file. But in the state output file, both the state
of being read in from the state input file, and calculated by the simulation function in Q4 are all included.
The first few lines of the state output file look like this:
time(day),S,I,R
0, 9999, 1,0
1, 9998.840016, 1.0885554285714287, 0.07142857142857142
2, 9998.66586733474, 1.1849501346490998, 0.1491825306122449
Finally, do not forget to call the method of close () to close a file object.
Transcribed Image Text:Purpose: To practice write a list of records to a tabular text file Degree of Difficulty: Moderate. In this question, your program will define a function named fnWriteState(), with two input parameters: · A list of records (the list of state of all days) · A string of a path name of the output file And there is no return values of this function. In this function, your program will write the list of state to a tabular file. It is notable that the output file should locate in the same folder of the a6.py file. In the state output file, the first line is names of the time, S, I and R. And lines from the second to the last line of the output file contain every day's state of S, I and R in the list of state, and also with the item of time (indicates the index of the day). Each record in the list of state will be written in one line. And the items of each line will be separated by commas. Basically, the format of the state output file is the same as the state input file. But in the state output file, both the state of being read in from the state input file, and calculated by the simulation function in Q4 are all included. The first few lines of the state output file look like this: time(day),S,I,R 0, 9999, 1,0 1, 9998.840016, 1.0885554285714287, 0.07142857142857142 2, 9998.66586733474, 1.1849501346490998, 0.1491825306122449 Finally, do not forget to call the method of close () to close a file object.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr