1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
KonstantinChe [14]
3 years ago
5

Task 1 – File Input

Computers and Technology
1 answer:
e-lub [12.9K]3 years ago
3 0

Answer:

Check the explanation

Explanation:

using System;

using System.IO;

                 

public class Program

{

 

  public static void Main()

  {

      string[] lines;

      Console.WriteLine("enter name of the file");

      String fileName=Console.ReadLine();

     

      Console.WriteLine("enter path of the file");

      String filePath=Console.ReadLine();

     

      using (StreamReader streamReader = File.OpenText(filePath))

      {

          String text = streamReader.ReadToEnd();

          lines = File.ReadAllLines(filePath);

      }

      Console.WriteLine("Enter path of the file to write");

      String outputFilePath = Console.ReadLine();

      bool fileExist = File.Exists(outputFilePath);

      if (fileExist)

      {      

                  overWriteOrChangeFileName(outputFilePath);          

      }

      else

      {

          File.Create(outputFilePath);

          File.WriteAllLines(outputFilePath, lines);

      }

      Console.Write("Input file Path"+filePath);

      Console.Write("output file path"+outputFilePath);

     

      void overWriteOrChangeFileName(String filePathtoCheck){

          Console.WriteLine("File exists. Do you want to overwrite the file or do you want to change the location and file name of the new file.Press Y to overwrite and press C to change the location and filename");

          String userInput=Console.ReadLine();

          if(userInput.Equals("Y")){

File.WriteAllLines(outputFilePath, lines);

          }else{

              Console.WriteLine("enter new path of the file including filename");

              String NewFileName=Console.ReadLine();

              outputFilePath=NewFileName;

              if(File.Exists(outputFilePath)){

                  overWriteOrChangeFileName(outputFilePath);                  

              }

              else

      {

          File.Create(outputFilePath);

          File.WriteAllLines(outputFilePath, lines);

      }

          }

      }

  }

 

}

You might be interested in
A(n) ________ converts your voice's sound waves into digital signals.
Montano1993 [528]
Analog-to-digital converter chip
8 0
3 years ago
What is the computer that is connected to a<br> server
sergiy2304 [10]

Answer:

peripheral device network connection

5 0
2 years ago
Read 2 more answers
_______ data would be useful for creating a weekly status report for your manager that should reflect changes in real time.     
elena55 [62]
D. Field data because that it a report of what happened over the week that a manager can reflect on for possible changes.
3 0
3 years ago
Read 2 more answers
Which statement is NOT true:
RSB [31]

Answer:

The correct answer for the given question is   "Machine languages can be used to write programs that can run on any machine."

Explanation:

The machine language consist of binary digit i. e 0 and 1 .Computer can understand only the machine language .The machine language consist of code that is written in bits so it is used  to express algorithms.When any program is compiled the compiler are converted into machine code so the machine language is produced by the compiler .

Machine language cannot used to write a program that run on any machine.

5 0
3 years ago
There are generally two ways of implementing dynamic programming solutions to problems, which have equal asymptotic time complex
san4es73 [151]

Answer:

1) Bottom-up

2) Top-down

Explanation:

In general dynamic programming is a divide and conquer strategy which can be implemented using bottom up approach or top down approach.

Bottom-up approach in dynamic programming will solve a relatively simple sub-problem first and then use the solution to build and arrive at solutions to a bigger sub-problem.

Top down approach is reversed to bottom-up approach and is also known as Memoization Method. Instead of solving a problem started from the base state sub-problem, the top down approach break a problem into a smaller problems from the top most destination state until it reaches the bottom most base state.

8 0
3 years ago
Other questions:
  • Declare a character variable letterStart. Write a statement to read a letter from the user into letterStart, followed by stateme
    12·1 answer
  • In controlling network traffic to minimize slow-downs, a technology called ________ is used to examine data files and sort low-p
    15·1 answer
  • If 10 ft lb of torque is applied at gear A, then what is the output torque at gear D?
    15·1 answer
  • The primary key is a field that uniquely and completely identifies a record.
    14·2 answers
  • When a Python script is running as a standalone program, what will the __name__ variable be set to?
    7·1 answer
  • Which of the following answers refers to a system containing mappings of domain names to various types of data, such as numerica
    15·1 answer
  • T F Changes to a function parameter always affect the original argument as well.
    15·1 answer
  • a. Daily Life Magazine wants an analysis of the demographic characteristics of its readers. The marketing department has collect
    13·1 answer
  • A SOCCER club uses ICT to
    10·1 answer
  • Helpppppppppppppppppppppppppppppppp
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!