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
4. What is an example of a Trans receiver? *<br> A. Pager<br> B. Wi-Fi<br> C. Telephone
Charra [1.4K]
I really think it A : pager
I hope this helps !!
8 0
2 years ago
Stephen needs to insert a field into a building block that will contain variable data. Which keyboard shortcut can he use to tog
STatiana [176]

Answer:

Alt + F9

Explanation:

The Keyboard shortcut that Stephen can use use to toggle between data and the field codes is Alt + F9. This is in regards to Microsoft Word Fields for both Windows and Mac operating systems. Although ALT + F9 will toggle between these two but for all the fields within the document. If you want to toggle between a single or various fields it would be Shift + F9.

8 0
2 years ago
Which type of keyboard improves accuracy and reduces the strain on the wrists?
klasskru [66]
That would be an Ergonomic keyboard, due to the fact that it is laid out in such a way that doesn't harm your wrists
4 0
2 years ago
Read 2 more answers
Write a Python 3 program to read from a .csv file containing rates from power companies. Your program should determine the avera
aliya0001 [1]

Answer:

In python:

file = open("rates.csv", "r")

ratecount = 0

ratesum = 0

mylist = []

rates = file.readlines()

for nums in rates:

     num = nums.rstrip('\n')

     mylist.append(int(num))

     for i in num:

           ratesum= ratesum + int(i)

           ratecount = ratecount + 1

print("Maximum Rate: "+str(max(mylist)))

print("Minimum Rate: "+str(min(mylist)))

print("Average Rate: "+str(ratesum/ratecount))

Explanation:

This opens the csv file

file = open("rates.csv", "r")

This initializes the number of rates in the file

ratecount = 0

This initializes the sum of the rates

ratesum = 0

This initializes an empty list

mylist = []

This reads the rates into lines

rates = file.readlines()

This iterates through the rates (as a string)

for nums in rates:

This removes the newline character \n in the rates

     num = nums.rstrip('\n')

This appends the rates (as an integer) to the empty list

     mylist.append(int(num))

The following counts the rates in the file and also sum them up

<em>      for i in num: </em>

<em>            ratesum= ratesum + int(i) </em>

<em>            ratecount = ratecount + 1 </em>

This prints the maximum of the rates

print("Maximum Rate: "+str(max(mylist)))

This prints the minimum of the rates

print("Minimum Rate: "+str(min(mylist)))

This calculates and prints the average rate

print("Average Rate: "+str(ratesum/ratecount))

6 0
3 years ago
What are common tasks Human Services workers perform? Check all that apply.
Ainat [17]

Answer: B, D, E, F

Explanation:

I got I right.

7 0
3 years ago
Read 2 more answers
Other questions:
  • A ____ is harmful computer code that spreads without your interaction, slipping from one network to another and replicating itse
    15·1 answer
  • Forms open in _______, which provides a user-friendly interface for entering data.
    11·1 answer
  • You are asked to optimize a cache design for the given references. Th ere are three direct-mapped cache designs possible, all wi
    7·1 answer
  • Secure Wi-Fi networks and VPNs use _____ to secure data transferred over a network.
    13·1 answer
  • The Springfork Amateur Golf Club has a tournament every weekend. The club president
    7·1 answer
  • 1. Define lexemes. Give an example of an lexeme in any programming language.<br>​
    10·1 answer
  • What is the data and information with example? ​
    9·1 answer
  • Where can formatting features be found ?! Need help asp !‍♀️
    9·1 answer
  • What are the characteristics of computer. Explain any one​
    15·2 answers
  • as a pc technician, you are on the road most of the day and use a laptop. when you get back to your office at the end of the day
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!