Chapter 8 Text Files.pdf

# Chapter 8 Text Files.pdf - Chapter 8 Text Files Section 8.1...

• 14

This preview shows pages 1–4. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

6. Each record of the file UN.txt contains four pieces of information (name, continent, population in millions, area) about one of the 192 member countries of the United Nations. The first two lines of the file are Afghanistan,Asia,28.2,251772 Albania,Europe,3.2,11100 What is the first line of the file created by the following code? Dim query = From line In IO.File.ReadAllLines("UN.txt") Let data = line.Split(","c) Let country = data(0) Let continent = data(1) Select country & " is in " & continent IO.File.WriteAllLines("NewFile.txt", query) (A) Afghanistan is in Asia (B) Albania is in Europe (C) country is in continent (D) The new file will be empty. Answer is A 7. Each line of the file UN.txt contains four pieces of information (name, continent, population in millions, area) about one of the 192 member countries of the United Nations. The first two lines of the file are Afghanistan,Asia,28.2,251772 Albania,Europe,3.2,11100 What is the first line of the file created by the following code? Dim query = From line In IO.File.ReadAllLines("UN.txt") Let data = line.Split(","c) Let country = data(0) Let population = 1000000 * CDbl(data(2)) Select country & "," & population IO.File.WriteAllLines("NewFile.txt", query) (A) Afganistan,28.2 (B) Afganistan,28,200,000 (C) Afganistan,28200000 (D) country,population Answer C 8. Each line of the file UN.txt contains four pieces of information (name, continent, population in millions, area) about one of the 192 member countries of the United Nations. The first two lines of the file are Afghanistan,Asia,28.2,251772 Albania,Europe,3.2,11100 What is the first line of the file created by the following code? Dim query = From line In IO.File.ReadAllLines("UN.txt") Let data = line.Split(","c) Let country = data(0) Let population = 1000000 * CDbl(data(2)) Let area = CDbl(data(3)) Let density = population / area Select country & "," & density.ToString("N1") IO.File.WriteAllLines("NewFile.txt", query) (A) Afganistan,28200000/251772 (B) Afganistan,112.0 (C) Afganistan,112.006100757829 (D) country,density Answer is B
9. What elements are in the array newArray after the following code is executed? Dim firstArray() As Integer = {1, 2, 3} Dim secondArray() As Integer = {3, 4, 5, 6} Dim newArray() As Integer = firstArray.Intersect(secondArray).ToArray (A) 1, 2, 3, 3, 4, 5, 6 (B) 1, 2, 3, 4, 5, 6 (C) 3 (D) 1, 2 Answer is C 10. What elements are in the array newArray after the following code is executed? Dim firstArray() As

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Winter '17
• .NET Framework

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern