4
.docx
keyboard_arrow_up
School
ECPI University, Virginia Beach *
*We aren’t endorsed by this school
Course
206
Subject
Computer Science
Date
Apr 3, 2024
Type
docx
Pages
3
Uploaded by CorporalStarEel5762
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Complete the program by filling in the code to read the file (goog.csv) and print the date and first price from each line. Compute the high and low price from the file and save the dates for the high and low price. Print them at the end.
HINT: Remember to open the file and check if that open command succeseded using the fail() method. When reading lines from a file, it makes sense to read all parts in the while condition.
infile.open(filename);
while(infile >> name >> value >> theRest) {
// Process input
}
infile.close();
If the program files to open the file:
Enter the name of the file to be analyzed:amzn.csvFile amzn.csv cannot be opened.
code:
#include <iostream>#include <limits>#include <fstream>
using namespace std;
//Todo: declare your functions here.int main(){ifstream infile;char fileName[256];cout <<"Enter the name of the file to be analyzed:";cin >> fileName;
// TODO: Open the filename and test that it was…
arrow_forward
Which file open flag causes the contents of an existing file to be discarded and the file size reduced to zero?
arrow_forward
How can you read a text file one line at a time?
A. By using the read() command with no parameters.
B. By specifying "o" as the mode parameter in the open() command.
C. By using the singleLine() string method.
D. By using the file object variable as the sequence in a for loop command.
After opening a file, how can you advance the file position to a particular offset within the file?
A. The only way to get to a particular offset within the file is to first read a particular number of characters.
B. By using the position() command, specifying the offset as a parameter.
C. By using the seek() command, specifying the offset as a parameter.
D. By using an index and square brackets on the file object.
What does line.split(";")
A. separates the string contained in line at every occurrence of semi-colon
B. separates the string contained in line at every occurrence of comma
C. separates the string contained in line at the first occurrence of a comma
D. concatenates…
arrow_forward
chown bob:bin file.txt
Which of the following statements are true ? ( Choose two.)
a. This changes the user owner of file.txt to bin.
b. This changes the user owner of file.txt to bob.
c. This changes the group owner of file.txt to bin
d. This changes the group owner of file.txt to bob.
arrow_forward
Which of the following is a correct opening of a file for writing to the file?
Lütfen birini seçin:
a. open(data.txt, "w")
b. file = open("data.txt", "write")
c. file = open(data.txt, "w")
d. file = open("data.txt", "w")
e. file = open("data.txt", "r")
arrow_forward
9..
Pls
arrow_forward
you will need to create the following textbook specified files. Use vi to create these files:
test-file1 test-file2 test-file3 test-g test-sor respected test-u west coast alpha1 alpha2 practice caffeine names.tmp numbers.tmp
What command results in a listing of the number of words and the number of lines in the files practice?
arrow_forward
Add a command to this chapter’s case study program that allows the user to view the contents of a file in the current working directory. When the command is selected, the program should display a list of filenames and a prompt for the name of the file to be viewed.
Be sure to include error recovery in the program. If the user enters a filename that does not exist they should be prompted to enter a filename that does exist.
arrow_forward
Programming
arrow_forward
All I need is the main.cpp file
Programming Specifications:
Task: Two files have been provided (wordcounter.h and wordcount.cpp). You must open a text file, read in each word until end of file, add each word to the WordCount library and print the report.
Your program must request a filename of a text file that contains words to count. You must check to see if it is a valid file and issue an error message if not and request a new file name until a valid one is entered.
You must have at least one function that either passes in a parameter and at least one function that returns a value. You can have a single routine that does both.
You must declare the class object properly, use AddWord() to add the word to the catalog and use PrintSummary() to produce the output.
Design Considerations:
The file will contain only words (no punctuation or special characters) less than or equal to 13 letters. There will be no limit to the number of words.
You must open the file and read each…
arrow_forward
you will need to create the following textbook specified files. Use vi to create these files:
test-file1 test-file2 test-file3 test-g test-sor respected test-u west coast alpha1 alpha2 practice caffeine names.tmp numbers.tmp
A file called empnames contains many employee names, with exactly one name on each line. What command outputs the names in the file in multiple columns, with columns before rows?
arrow_forward
Q4: Write m file to read a student degree and show the result SUCCESS, or Fail
arrow_forward
Task – IV:
Write a program that makes a copy of the file. Your program will ask the user for the source file and
the new file names and then will read a line at a time from the input (source) file and prints it to the
output (new file) file with a line number.
You can create your own file "sample.txt" and add your favorite poem.
arrow_forward
Which of the following
statements is not correct
regarding the opening
modes of a file?
a. When you open a file
for writing, if the file
does not exist, an error
Occurs.
b. When you open a file
for writing, if the file
does not exist, a new
file is created.
c. When you open a file
for reading, if the file
does not exist, an error
Occurs.
d. When you open a file
for writing, if the file
exists, the existing file is
overwritten with the
new data.
arrow_forward
Which file open flag forces all output to occur at the end of the file?
arrow_forward
A student wants to write into a file called myfile, without deleting its existing content. Which one of the following functions should he or she use?
f = open('myfile', 'r')
f = open('myfile', 'w+b')
f = open('myfile', '+')
f = open('myfile', 'a')
arrow_forward
Write the program FileComparison that compares two files. Two files have been provided for you, Quote.txt and Quote.docx, both containing movie quotes and are located in the /root/sandbox/ directory
Note: you will not be able to see the Quote.docx file.
Next write the file comparison application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a file’s size, you can create a System.IO.FileInfo object using statements such as the following, where FILE_NAME is a string that contains the name of the file, and size has been declared as an integer:
FileInfo fileInfo = new FileInfo(FILE_NAME); size = fileInfo.Length;
Your program's output should look like the following:
The size of the Word file is FILE_SIZE and the size of the Notepad file is FILE_SIZE The Notepad file is x% of the size of the Word file
using System;
using static System.Console;
using System.IO;
class FileComparison
{
static void Main()
{
// Getting…
arrow_forward
You develop a Python application for your school.You need to read and write data to a text file. If the file does not exist, it must be created. If the file has content, the content must be removed.Which code should you use?
Group of answer choices
C. open(“local_data”, “w+”)
D. open(“local_data”, “w”)
A. open(“local_data”, “r”)
B. open(“local_data”, “r+”
arrow_forward
Instructions
Add a command to this chapter’s case study program that allows the user to view the contents of a file in the current working directory. When the command is selected, the program should display a list of filenames and a prompt for the name of the file to be viewed.
Be sure to include error recovery in the program. If the user enters a filename that does not exist they should be prompted to enter a filename that does exist.
An example of the program input and output is shown below:
/root/sandbox 1 List the current directory 2 Move up 3 Move down 4 Number of files in the directory 5 Size of the directory in bytes 6 Search for a file name 7 View the contents of a file 8 Quit the program Enter a number: 7 Files in /root/sandbox: filesys.py example.txt Enter a file name from these names: example.txt THIS IS CONTENT OF AN EXAMPLE FILE. /root/sandbox 1 List the current directory 2 Move up 3 Move down 4 Number of files in the directory 5 Size of the directory in bytes 6…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Related Questions
- Complete the program by filling in the code to read the file (goog.csv) and print the date and first price from each line. Compute the high and low price from the file and save the dates for the high and low price. Print them at the end. HINT: Remember to open the file and check if that open command succeseded using the fail() method. When reading lines from a file, it makes sense to read all parts in the while condition. infile.open(filename); while(infile >> name >> value >> theRest) { // Process input } infile.close(); If the program files to open the file: Enter the name of the file to be analyzed:amzn.csvFile amzn.csv cannot be opened. code: #include <iostream>#include <limits>#include <fstream> using namespace std; //Todo: declare your functions here.int main(){ifstream infile;char fileName[256];cout <<"Enter the name of the file to be analyzed:";cin >> fileName; // TODO: Open the filename and test that it was…arrow_forwardWhich file open flag causes the contents of an existing file to be discarded and the file size reduced to zero?arrow_forwardHow can you read a text file one line at a time? A. By using the read() command with no parameters. B. By specifying "o" as the mode parameter in the open() command. C. By using the singleLine() string method. D. By using the file object variable as the sequence in a for loop command. After opening a file, how can you advance the file position to a particular offset within the file? A. The only way to get to a particular offset within the file is to first read a particular number of characters. B. By using the position() command, specifying the offset as a parameter. C. By using the seek() command, specifying the offset as a parameter. D. By using an index and square brackets on the file object. What does line.split(";") A. separates the string contained in line at every occurrence of semi-colon B. separates the string contained in line at every occurrence of comma C. separates the string contained in line at the first occurrence of a comma D. concatenates…arrow_forward
- chown bob:bin file.txt Which of the following statements are true ? ( Choose two.) a. This changes the user owner of file.txt to bin. b. This changes the user owner of file.txt to bob. c. This changes the group owner of file.txt to bin d. This changes the group owner of file.txt to bob.arrow_forwardWhich of the following is a correct opening of a file for writing to the file? Lütfen birini seçin: a. open(data.txt, "w") b. file = open("data.txt", "write") c. file = open(data.txt, "w") d. file = open("data.txt", "w") e. file = open("data.txt", "r")arrow_forward9.. Plsarrow_forward
- you will need to create the following textbook specified files. Use vi to create these files: test-file1 test-file2 test-file3 test-g test-sor respected test-u west coast alpha1 alpha2 practice caffeine names.tmp numbers.tmp What command results in a listing of the number of words and the number of lines in the files practice?arrow_forwardAdd a command to this chapter’s case study program that allows the user to view the contents of a file in the current working directory. When the command is selected, the program should display a list of filenames and a prompt for the name of the file to be viewed. Be sure to include error recovery in the program. If the user enters a filename that does not exist they should be prompted to enter a filename that does exist.arrow_forwardProgrammingarrow_forward
- All I need is the main.cpp file Programming Specifications: Task: Two files have been provided (wordcounter.h and wordcount.cpp). You must open a text file, read in each word until end of file, add each word to the WordCount library and print the report. Your program must request a filename of a text file that contains words to count. You must check to see if it is a valid file and issue an error message if not and request a new file name until a valid one is entered. You must have at least one function that either passes in a parameter and at least one function that returns a value. You can have a single routine that does both. You must declare the class object properly, use AddWord() to add the word to the catalog and use PrintSummary() to produce the output. Design Considerations: The file will contain only words (no punctuation or special characters) less than or equal to 13 letters. There will be no limit to the number of words. You must open the file and read each…arrow_forwardyou will need to create the following textbook specified files. Use vi to create these files: test-file1 test-file2 test-file3 test-g test-sor respected test-u west coast alpha1 alpha2 practice caffeine names.tmp numbers.tmp A file called empnames contains many employee names, with exactly one name on each line. What command outputs the names in the file in multiple columns, with columns before rows?arrow_forwardQ4: Write m file to read a student degree and show the result SUCCESS, or Failarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- COMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L