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]
4 years ago
5

Task 1 – File Input

Computers and Technology
1 answer:
e-lub [12.9K]4 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
Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
EastWind [94]

Answer:

Following are the code to the given question:

def shampoo_instructions(num_cycles):#defining a method shampoo_instructions that accepts num_cycles as a parameter

   if num_cycles < 1:#defining an if block that num_cycles value is less than 1

       print('Too few.')#print message  

   elif num_cycles > 4:#defining elif block that checks num_cycles is greater than 4

       print('Too many.')#print message  

   else:#defining else block

       N= 1;#defining N variable that holds a value 1

       for N in range(N, num_cycles+1):#defining for loop that check value in range

           print(N , ": Lather and rinse.")#print message  

       print('Done.')#print message  

shampoo_instructions(2)#calling the method

Output:

1 : Lather and rinse.

2 : Lather and rinse.

Done.

Explanation:

In this code, a method "shampoo_instructions" is defined, that accepts a variable "num_cycles" in its parameter, and in the next step, the multiple conditional statements have used that check the "num_cycles" values which can be defined as follows:

  • The if the block checks the parameter value is less than 1, and it prints the value as the message.
  • In the next step, the elif block is used that checks parameter value is greater than 4, and it prints the value as the message.
  • In the else block, it uses the for loop that checks the value in the range and prints its value and calling the method.
6 0
3 years ago
Explain what an IM is, and what is the technology shown in the accompanying figure
sergiy2304 [10]

Answer: Instant Message

Explanation:

7 0
3 years ago
Read 2 more answers
You have a shared folder named Reports. Members of the Managers group have been given Write access to the shared folder. Mark Ma
Anna71 [15]

Answer:

Following are the solution to the given question:

Explanation:

The common folder called Report has also been shared. Writing access to a shared folder was given to management group members. Mark is a member of a group of managers. We can access the files within your reporting directory, but you really should not access the Confidential.xls file. We want to add Mark Mangum to our ACL files using Deny permissions on Confidential.xls.

5 0
3 years ago
Which language paradigm interacts well with database systems in business environments that use SQL?
HACTEHA [7]
The answer is C, can you mark me brain
6 0
3 years ago
Create a stored procedure sp_Q1 that takes two country names like 'Japan' or 'USA' as two inputs and returns two independent set
wolverine [178]

Answer:

Kindly note that, you're to replace "at" with shift 2 as the brainly text editor can't take the symbol

If you are executing this script with any other script, Add "GO" to the line above "CREATE PROCEDURE", on a line all by itself, and it should fix that error of 'CREATE/ALTER PROCEDURE'

Explanation:

CREATE PROCEDURE sp_Q1

"at"country1 NVARCHAR(15),

"at"country2 NVARCHAR(15)

AS

BEGIN

  BEGIN

      SELECT SupplierID, CompanyName, Phone, Country FROM suppliers

      where Country in ("at"country1,"at"country2)

     

  SELECT ProductID, ProductName, UnitPrice, SupplierID FROM Products

      where SupplierID in(

      SELECT SupplierID FROM suppliers

      where Country in ("at"country1,"at"country2)) ORDER BY SupplierID

  END

END

GO

-- Testing script.

DECLARE "at"RC int

DECLARE "at"country1 nvarchar(15)

DECLARE "at"country2 nvarchar(15)

-- Set parameter values here.

set "at"country1='UK'

set "at"country2='Canada'

EXECUTE "at"RC = [dbo].[sp_Q1]

"at"country1

,"at"country2

GO

5 0
4 years ago
Other questions:
  • Plagiarism occurs when writers
    14·2 answers
  • Crashing almost always accelerates the schedule while increasing project risk, whereas fast tracking almost always accelerates t
    10·1 answer
  • What is a catalyst? a chemical found in leaves a chemical which promotes a chemical reaction a chemical which reacts with sunlig
    10·1 answer
  • In many cases, a ribbon organizes buttons and options in Select one: a. menus. b. sections. c. toolbars. d. groups.
    9·2 answers
  • The term integration refers to the ability to
    9·1 answer
  • Write a computer program that determines how many grades are between 0 and 19.
    8·1 answer
  • 7. Define ports including standard and<br>specialized ports. Give examples of each.​
    11·1 answer
  • 100 POINTS!!!!!!!!
    6·2 answers
  • How to add links in HTML? ​
    8·1 answer
  • I'll give u 16 points answer thisss
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!