Question

In: Physics

c# only please Objectives Use the more advanced data structures introduced to accomplish a difficult problem....

c# only please

Objectives

  • Use the more advanced data structures introduced to accomplish a difficult problem.

Tasks

This assignment has two parts:

  1. Read from a file.
  2. Write to a file.

Task 1 – File Input

The first piece of information we need is a text file’s name and location. Ask the user through the console what the file’s name and location are. After that, please ensure that the file does exist and at the given location. If the file does not exist or cannot be read, please return a message to the user stating that and ask them to enter another name and location.

Finally, if the file can be read then simply copy/read every line from the file. The contents of this file will be used in the next task.

Task 2 – File Output

Ask the user, through the console, what the name of the copy of the previous file should be called and where it should be saved. Check to see if a file with the same name already exists at the location given and if one does ask the user if they want to overwrite the file that already exists or if they would like to change the name and location of the new file. If they wish to change the name and location, go through the process of getting their input again through the console and checking if the newly given name and location are taken already too.

If they want to overwrite or no file already exists in the given location with the given name, then place the copied contents of the file that was read in the first task into this new file.

After successfully copying the contents of the first file into the second file, print to the console the name and location of both of those files.

A sample text file named “textfile.txt” has been supplied in case you need a file to test the above code on. The contents of that file is the declaration of independence.

∃ Some Sample Output:

Please enter a text file name and location:

C:\Users\source\repos\1322L_Assignment6\bin\Debug\textfiladsfe.txt22

This file does not exist!

Please enter a text file name and location:

C:\Users\source\repos\1322L_Assignment6\bin\Debug\textfile.txt

Please enter a new file name and location:

C:\Users\source\repos\1322L_Assignment6\bin\Debug\DeclarationOfIndependence.txt

A file already exists with that name!

Would you like to overwrite it or enter a different name? (0 or 1) 0

The file will be overwritten.

The file “C:\Users\source\repos\1322L_Assignment6\bin\Debug\textfile.txt” has been copied to “C:\Users\source\repos\1322L_Assignment6\bin\Debug\DeclarationOfIndependence.txt”.

Solutions

Expert Solution


Related Solutions

THE STRING MATCH PROBLEM C++ only. Must use loops. Please do not use sequence of if...
THE STRING MATCH PROBLEM C++ only. Must use loops. Please do not use sequence of if statements. . Given 2 strings, a and b, set result to the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings. • for input of "xxcaazz", "xxbaaz" → 3 • for input of "abc", "abc" → 2 • for input...
Objectives: Practice using selection structures within a complete C++ program to solve a problem. Be able...
Objectives: Practice using selection structures within a complete C++ program to solve a problem. Be able to understand and use linear interpolation in a program. Modify/Extend an existing program. Problem Description: Linear Interpolation There are two credit levels for this assignment. Completing the “B” level correctly is worth 16/20 points, completing the “A” level is worth 20/20. You are encouraged to get the code for the “B” level working first and then complete the “A” level if you have time/interest....
this is data structures with C++ language, please do "#1 & a" separately and please send...
this is data structures with C++ language, please do "#1 & a" separately and please send me copyable file 1. Write a program that allows the user to enter the last names of the candidates in a local election and the votes received by each candidate. The program should then output each candidate's name, votes received by that candidate, and the percentage of the total votes received by the candidate. Assume a user enters a candidate's name only once and...
Use excel only, please! problem #1 data contains data on automobile manufacturer who employs sales representatives...
Use excel only, please! problem #1 data contains data on automobile manufacturer who employs sales representatives who make calls on dealers. The manufacturer wishes to compare the effectiveness of four different call-frequency plans for the sales representatives. Thirty-two representatives are chosen at random from the sales force and randomly assigned to the four call plans for six months, and their sales for the 6-month study period are recorded. Do the sample data support the hypothesis that at least one of...
Please consider the following data. The data will be used for the entire problem. Only move...
Please consider the following data. The data will be used for the entire problem. Only move forward the viable investments to the next capital rationing model. Meaning if the investment passes the capital rationing test, put that investment into the next model. i.e. if one of the investments doesn’t pass the payback test, don’t move it forward to ROR. Bonnet Corporation is considering 8 different investments. Here is the data for the 8 investments: McCoy Stede Rackham Lavasseur Anthos Investment...
(Problem is from the textbook Data Structures using C++) Add a function to the dateType class....
(Problem is from the textbook Data Structures using C++) Add a function to the dateType class. The function's name is compareDates. Its prototype is int compareDates(const dateType& otherDate; The function returns -1 if otherDate is greater than than this date The function returns 0 if otherDate equals this date The function returns 1 if otherDate is less than this date Examples dateType d1(1, 1, 2019); dateType d2(11,1, 2019) d1.compareDates(d2) returns -1 d2.compareDates(d1) returns 1 d2.compareDates(d2) returns 0 <<<<< dateType.h >>>>>>...
This assignment uses data structures, selection, use, control structures, logic, computation, file I/O, etc. In C++...
This assignment uses data structures, selection, use, control structures, logic, computation, file I/O, etc. In C++ There should be 3 files for the project: theMain.cpp, dateClass.h, dateClass.cpp (or similar file names) For input/output. Read at least 10 dates in a data file set up this way: The first number is the number of data items in the file. Then after that, each row is one date in the format month day year. here is a sample data file of 6...
In C++, use SML programs to accomplish each of the following tasks: a) Use a sentinel-controlled...
In C++, use SML programs to accomplish each of the following tasks: a) Use a sentinel-controlled loop to read positive numbers and compute and display their sum. Terminate input when a negative number is entered. b) Use a counter-controlled loop to read seven numbers, some positive and some negative, and compute and display their average. c) Read a series of numbers, and determine and display the largest number. The first number read indicates how many numbers should be processed. For...
You are required to use only C for this problem. To begin, instead of using two...
You are required to use only C for this problem. To begin, instead of using two different variables for this problem, you are going to define a structure with two members; one representing the feet and the other one representing the inches. We will also use three functions; one to initialize a structure, one to check the validity of its values, and the last one to print them out. First, define your structure. Next, declare a structure of this type...
Be sure to use only C for the Programming Language in this problem. Before we start...
Be sure to use only C for the Programming Language in this problem. Before we start this, it is imperative that you understand the words “define”, “declare” and “initialize” in context of programming. It's going to help you a lot when following the guidelines below. Let's begin! Define two different structures at the top of your program. be sure to define each structure with exactly three members (each member has to be a different datatype). You may set them up...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT