Saving a Document as a Text File
Q: Your Own Linked List Design your own linked list class to hold a series of integers. The class…
A: The C++ code is given below with output screenshot
Q: File Display ProgramWrite a program that asks the user for the name of a file. The program should…
A: Source code of the given problem is in step 2.
Q: Requirements for Your M5 Assignment 1 Pseudocode for Program Integration For the first module, write…
A: Solution: Given, From the random module import randint to roll each die randomly # in…
Q: A function is similar to a procedure or sub-module but a function can do this _________ while a…
A: let us see the answer:- 1) The correct option is c) Return a value. Explanation:-A Sub Procedure…
Q: Coose corect option: q. _________________ is used to open the sequential file access for append.…
A: Choose correct option: Question. _________________ is used to open the sequential file access for…
Q: Write the code in python Create an application that can create, display, search and maintain the…
A: def CreateBook(): book = open("book.txt", "w") while True: bookName = input("Enter your…
Q: Create an application that writes a series of random numbers to a file. Each random number should be…
A: Start Visual Studio. Open a new project and name it as “RandomNumberFileProject”. Add a new form…
Q: Average Number of Words If you have downloaded the source code from the Computer Science Portal you…
A: The answer is..
Q: Which one of the following function is capable of reading a file into a string variable?
A: file_get_contents() - This function is the preferred way to read the contents of a file into a…
Q: The function file_first_chars in python takes one parameter, fname, the name of a text file, and…
A: Introduction: Programming involves dealing with files on a regular basis. Python has built-in…
Q: C Sharp Random Number File writer Create an application that writes a series of random numbers to a…
A: According to the requirement , kindly find the below solution: Here we have a new Windows Forms…
Q: please code in python redact_file: This function takes a string filename. It writes a new file that…
A: The redact_file function is a Python function that takes a filename as input and creates a new file…
Q: Print Person Information from file In this lab you are asked to complete the function :…
A: ########################## Complete this function#########################def…
Q: in c # i need to Write the program FileComparison that compares two files. Two files have been…
A: It seems that the files is not correctly placed in the location: /root/sandbox/directory One more…
Q: Finish this program from the code posted below! Note: There should be two files Main.py and…
A: Code in python , Added implementation for edit contact functtion , and main function according to…
Q: ask: Loading data from files This exercise will require you to load some information from files and…
A: Java code is implemented below
Q: 2) Write a program called data_collection.py to accept input from the user and create a .csv file…
A: source code import csv def add(): with open(f_name, 'a') as c_file: c_wrt =…
Q: This program will have three functions, the main() create() and retrieve(). main() will call…
A: Program: #Defining the function create() def create(): #open the file grades_file =…
Q: # Write your code below each prompt # Create a function called ex2() which: # 1. Prompts the user…
A: I have provided PYTHON CODE , CODE SCREENSHOT , TXT FILE SCREENSHOT and OUTPUT…
Q: 1. save_friendsdb This function takes two arguments, friendsdb and filename. It opens up the file…
A: According to the information given:- We have to create a save_friendsdb with 2 argument friendsdb…
Q: Create a function called file_reader() with the following parameters/arguments: a. file_to_read ●…
A: The fopen() function is also used to create a file. Maybe a little confusing, but in PHP, a file is…
Q: When the user to selects the "view_mine" option, the program does not work as expected. It prints…
A: Hello student. Greetings Hope you are doing great. Thank you!!! The modification in the code is in…
Q: main() will call create() and then call retrieve() create() will prompt the user to enter any…
A: Program: #Defining the function create() def create(): #open the file grades_file =…
Q: How to fix my error? assignment question This program will have three functions, the main()…
A: There is a difference in the input expected by the test_2_io_case_2. It expects the input to be…
Q: 1. Creating Employee Data ( Page 625) Create an application that allows the user to enter the…
A: employee data:- Employee data is information about employees that is used for business purposes.…
Q: e takes one parameter, fname, the name of a text file. The function should open the file for…
A: We need to define the function called get_second_line that accepts the file name as input, opens the…
Q: Program Description: his assignment focuses on while loops and random numbers. Turn in a file named…
A: Please find the code below:
Q: Create the function that would allow you to add information about students (name, surname, field of…
A: Since you have not asked for any particular language. So i am answering the question in c++. in next…
Q: Twitter Data: twitter_url =…
A: Given a pandas dataframe containing Twitter data, write a function that calculates the number of…
Q: on the screen. Each line of screen output should be preceded with a line number, followed by a…
A: C++ program that will prompt the user for a file name, then display the contents of the file with…
Q: The Pinewood Derby involves racing Derby cards down multiple lanes and calculating the average time…
A: racers=int(input("Enter number of racers: ")) times=[] for i in range(racers): time=int(input("Enter…
Q: Menu option A -- Determine Hours to Study The program will READ in data from a text file named…
A: “Since you have posted multiple questions, we will provide the solution only to the first question…
Q: PROGRAM NEEDS TO MATCH EXAMPLE PHOTO Write a program ( lab6.cpp ) that gives and takes advice on…
A: #include<iostream>#include<fstream>using namespace std; int main(){…
Q: The File class contains file input and output operations. In other words, you can use the File class…
A: Given :- The File class contains file input and output operations. In other words, you can use the…
Q: To set up a file to perform file I/O, you must declare Group of answer choices at least one…
A: This question comes from Programming Language which is a paper of Computer Science. Let's discuss it…
Q: Write a function that takes two parameters, a file name to create and an integer. The function…
A: I have provided PYTHON CODE, CODE SCREENSHOT , OUTPUT SCREENSHOT and TXT FILE…
Q: Menu option B -- Determine Grade The program will READ in data from a text file named Grades.txt.…
A: To implement the program some considerations are made: If creditHours having bad input then…
Q: C Sharp Random Number File writer and Reader Create an application that writes a series of random…
A: Step 1: Open Microsoft Visual Studio. Select New Project -> Windows Form Application. Enter name…
Q: We will put the data into a file n_bikes.txt, one number per line, and will post it in this…
A: def main(): # Open mynumbers.txt for reading i=0 a=[] sum=0 myfile =…
Q: >> classicVinyls.cpp For the following program, you will use the text file called “vinyls.txt”…
A: #include<iostream> #include<fstream> using namespace std; //vinylRec structure struct…
Q: BAGGINS Trucking maintains a trip file in which each record contains the following data: DRIVER name…
A: The given data is BAGGINS Trucking maintains a trip file in which each record contains the following…
Q: Pendant Publishing edits multi-volume manuscripts for many authors. For each volume, they want a…
A: The company requires a labeling system for each volume, which includes the author's name, the title…
Saving a Document as a Text File
Create a function save_document() that accepts the arguments filename and text and saves the text into the file filename. The filename should use the name of the document with ‘_edited_document’ appended to it.
For example, for the document text.doc, the save document should have the name text_edited_document.txt. The file should be saved in the folder “edits.” Assume that the folder already exists in the present working directory.
Step by step
Solved in 2 steps with 6 images
- C++arrays, c-strings, functions with arrays as parameters 1. Create a file that contains 20 integers or download the attached file twenty_integers.txt Create a program that: 2. Declares a c-style string array that will store a filename. 3. Prompts the user to enter a filename. Store the file name declared in the c-string. 4. Opens the file. Write code to check the file state. If the file fails to open, display a message and exit the program. 5. Declare an array that holds 20 integers. Read the 20 integers from the fileinto the array.6. Write a function that accepts the filled array as a parameter and determines the MAXIMUM value in the array.Return the maximum value from the function (the function will be of type int).7. Print ALL the array values AND print the maximum value in the array using a range-based for loop. Use informational messages.Ensure the output is readable.Create a structure called applianceTvpe with the following members. Use the proper variable TYPES for the members: name; SUpplierlD: modelNo: cost; Create an array variable of type applianceType that can hold 50 components. Write the code segment to read from a file into the structure array. Declare an input file stream identifier for this purpose. Open the file and read until end of file. Keep a count of how many rows actually read. The data file contains the following data: RefrigeratorABC 80 4657 521.62 ToasterOven 100 3245 245.96 MicroWave 95 7878 345.67 Using a looping construct, output to the console (cout) the data read into the structure array. Make sure you do not go outside the bounds of the array or beyond the number of rows actually read. You do not need to write any #include statements, using statements and you do not have to write code to open the file. Assume the file is open. You do need to declare variables needed for the program segment.Please help with my C++Specifications • For the view and delete commands, display an error message if the user enters an invalid contact number. • Define a structure to store the data for each contact. • When you start the program, it should read the contacts from the tab-delimited text file and store them in a vector of contact objects. •When reading data from the text file, you can read all text up to the next tab by adding a tab character ('\t') as the third argument of the getline() function. •When you add or delete a contact, the change should be saved to the text file immediately. That way, no changes are lost, even if the program crashes later
- python function that creates and saves data in a file. the saved data represents exam grades. in the function , you will create n random numbers in the range 1-100, where n is the number of students. The function can be called as follows: createFile(filename, n) main function, in which the user inputs the file name and the number of students, then the main calls function createfile. the main should preform validation for n (should be > 0), and the filename(should end with .txt)Python Create a text file named “Books.txt”.Open the text file and add the name of at least two books.In your Python3 code file, create a function that will loop through and display a menuwith options to Display, Add, Exit. It will end once the user selects the option for exit.Create another function that will accept the user’s choice with the outcome for eachoption.Display – read the file and output each lineAdd – prompt the user for a book name and append it to the file. Exit – close the file and exit the loopRun the code to display your output.Open the project or solution named mpg in this folder: ex_starts\ch07_ex1_mpg Review the code and run the program to refresh your memory on how it works. Notice that, unlike the program in this chapter, this program lets the user perform more than one calculation, it stores the values the user enters in a text file, and it displays the total miles, total gallons, and average miles per gallon when the program starts and after each entry. Add a function that calculates the miles per gallon Define a function named calculate_mpg() before the main() function that calculates the miles per gallon. This function should accept two double values for the miles and gallons, round the result to two decimal places, and return the result as a double type. Modify the code in the main() function so it uses the calculate_mpg() function. Note that the miles per gallon is calculated in three different places. Move the definition for the calculate_mpg() function after the main() function. When you run…
- File redirection allows you to redirect standard input (keyboard) and instead read from a file specified at the command prompt. It requires the use of the < operator (e.g. java MyProgram < input_file.txt) True or FalseThis program will have three functions, the main() create() and retrieve(). main() will call create() and then call retrieve() create() will prompt the user to enter any number of course name / grade pairs and write them to a file named grades.txt. Pressing Enter with no input value on the course name will exit the loop, close the file, print "File was created and closed" and return the bool value True to the main() retrieve() will open and read grades.txt. The function then will print the course names and scores as shown below. The average score should be calculated as well as a simple GPA and displayed to two decimal places and then return variable used for the GPA to the main() . See sample run below in which 4 course names were entered, but note that more or fewer courses could have been entered. I need my grades.txt file to output course and grade in seperate lines (which I think I fixed) and work for the final output (not fixed). I am getting errors. I am not sure how to adjust…Monthly Sales Create a program that allows you to view and edit the sales amounts for each month of the current year. Example COMMAND MENU add - Add sales for specified month view - View sales for specified month edit - Edit sales for specified month totals - View sales summary for year exit - Exit program Command: add Three-letter Month: jan Sales Amount: 10317 Sales amount for Jan is 10,317.00. Command: add Three-letter Month: feb Sales Amount: 15293 Sales amount for Jan is 15,293.00. Command: view Three-letter Month: jan Sales Amount: 14317 Sales amount for Jan is 14,317.00. Command: edit Three-letter Month: jan Sales amount for Jan is 14,317.00. Command: totals Yearly total: 29,610.00 Monthly average: 14,805.00 Command: view Three-letter Month: july Invalid three-letter month. Command: exit Bye! Specifications The program should use a list to store the sales data for each month with the three-letter abbreviation for the month (Jan,…
- Status Date modified 3/9/2023 2:59 PM 3/9/2023 2:59 PM 3/9/2023 2:59 PM 3/9/2023 2:59 PM 3/9/2023 2:59 PM input miles Traveled input gallonsOfGasUsed start DEBUG01-02 - Notepad File Edit Format View Help // This pseudocode is intended to compute the number // of miles per gallon you get with your automobile. start Type Text Document Text Document Text Document JPG File Text Document milesPerGallon milesTraveled + gallonsOfGas. - output milsperGallon Size 1 KB 1 KB 1 KB 34 KB 1 KB#function read file and display reportdef displayAverage(fileName):#open the fileinfile = open(fileName, "r")#variable declaration and initializationtotal = 0count = 0#read filefor num in infile:total = total + float(num)count = count + 1#close the fileinfile.close()#calculate averageaverage = total / count#display the resultprint("Average {:.1f}".format(average)) #method callingdisplayAverage("numbers.txt")