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
m_a_m_a [10]
3 years ago
14

import java.io\.\*; import java.nio.file\.\*; public class TestFileReader { public static void main(String[] args) { Path p = Pa

ths.get("a.txt"); try (BufferedReader in = new BufferedReader( new FileReader(p.toFile()))) { String line = in.readLine(); while (line != null) { String[] v = line.split("::"); String lname = v[0]; String fname = v[1]; String dept = v[2]; System.out.println(fname + " " + lname + ", dept " + dept); line = in.readLine(); } } catch (FileNotFoundException e) { System.out.println("File not found."); } catch (IOException e) { System.out.println("I/O error."); } } } (Refer to code example 15-1.) What delimiter is used to separate fields in the a.txt file?
Computers and Technology
1 answer:
Charra [1.4K]3 years ago
6 0

Answer:

The delimiter use is "::".

Explanation:

The Java inbuilt String.split( ) function is use to split a String into an array of String.

The split( ) takes delimiter as arguments/parameter which determines at which point the string is to be broken down into different part/token.

From the above code snippet;

Each line in the file a.txt that is not null is splitted using the statement below:

String[ ] v = line.split("::");

The line is splitted using "::" as delimiter and the resulting array is then assigned to the variable 'v'.

For instance, a line in the file could take the form:

John::Smith::Music

When it is splitted,

String lname = John;

because lname make reference to index 0 of the array.

String fname = Smith;

because fname make reference to index 1 of the array.

String dept = Music;

and dept make reference to index 2 of the array.

You might be interested in
Assume that a variable variable, number Of Sides has been initialized. Write a statement that assigns the value True to the vari
inna [77]

Answer:

public class ANot {

   public static void main(String[] args) {

   

       int numberOfSides = 20;

       boolean isQuadrilateral;

       if(numberOfSides==4){

           isQuadrilateral = true;

           System.out.println("The triangle is quadrilateral");

       }

       else{

           isQuadrilateral=false;

           System.out.println("The triangle is not quadrilateral");

       }          

}

}

Explanation:

  1. Create and Initilize the int  variable numberOfSides (You can also receive this from a user using the scanner class for example).
  2. create a boolean variable isQuadrilateral
  3. Use if and else statement to check if numberOfSides ==4 and assign true to isQuadrilateral else assign false
7 0
3 years ago
Query: [mcdonalds Austin] Viewport: Fresh User Location: within Houston, TX Result Returned: McDonalds location in a neighboring
son4ous [18]

Answer:

The answer is "Option d"

Explanation:

Description to this query can be defined as follows:

  • All of the three (User location, Location modifier, and viewport) are used to identify range demotions.
  • The Viewport, the new user location in Houston, is a McDonald's address query, where the user looks for the exact location of McDonald's in the area of Austin.  
  • The location modifier and viewport are used to calculate the distance of the demotions Client position.
8 0
3 years ago
What is a layer, in the context of this lesson?
pshichka [43]

Answer:

A logical unit of a system.

Explanation:

i'm thinking your are talking about system layers such as the ISO? Layers help identify the order of how the whole system works.

7 0
2 years ago
Read 2 more answers
Using the scenario below, answer the following questions:
4vir4ik [10]

Answer:

Here is code in java.

import java.util.*;

class Main

{

public static void main (String[] args) throws java.lang.Exception

{

   try{

         boolean flag=false;

         int total_mile=0;

         double avg_mile;

       // part 1, create and initialize array

       int inp[]={2,5,9,11,13,17,20,22,24,26};

       

       System.out.print("miles ran per week: ");

       // print the miles per week of train

       for(int x=0;x<10;x++)

       {

       System.out.print(inp[x]+" ");

       }

        System.out.println();

       //part 2, print the value of index 2 in the list

       System.out.println("value at index 2: "+inp[2]+" miles");

       //part 3, find length of array

       System.out.println("list length: "+inp.length);

     

       // part 4, calculate total mile and average

       for(int y=0;y<10;y++)

       {

       total_mile=total_mile+inp[y];

       }

       System.out.println("total miles ran: "+total_mile+" miles");

       

       avg_mile=total_mile/10.0;

       System.out.println("average no of miles ran= "+avg_mile+" miles");

       

     // part 5, check 4 exist in the list or not

       for(int k=0;k<10;k++)

       {

       if(inp[k]==4)

       {

       flag=true;

       break;

           }

       }

           if(flag)

           System.out.println("4 exist in the list.");

           else

            System.out.println("4 doesn't exists in the list.");  

       

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create and initialize array with list value equals to 2 and maximum value 26. Print the miles of each week.Then find the value of miles at index 2 in the list.Next find the length of the array and print it.Calculate total miles ran of 10 weeks.Then calculate the average miles by dividing the total with 10. In the array, check 4 exist or not.

Output:

miles ran per week: 2 5 9 11 13 17 20 22 24 26                                                                            

value at index 2: 9 miles                                                                                                  

list length: 10                                                                                                            

total miles ran: 149 miles                                                                                                

average no of miles ran= 14.9 miles                                                                                        

4 doesn't exists

3 0
3 years ago
Which of the following is a basic concept associated with Web 2.0? Select one: a. shift in user's role from the passive consumer
soldier1979 [14.2K]

Answer:

A: shift in user's role from the passive consumer of content to its creator

Explanation:

During the phase of Web 2.0, consumers evolved from just been highly informed and socially connected (in other words, they evolved from being just passive consumers) to a more engaged and empowered consumer. This implied that consumers could easily adapt to new technologies to meet individual needs and create an emotional bond with brands. They evolved from passive consumers to being the creators of what they wanted to meet their specific needs.

5 0
3 years ago
Other questions:
  • When it comes to saving money, what is a good rule of thumb?
    5·2 answers
  • Harry needs to use a type of graph in a spreadsheet to show variations in data over a specific period. What type of graph or cha
    11·2 answers
  • P**nhub or x-videos or other
    9·1 answer
  • Given the function definition
    12·1 answer
  • You should use html elements instead of server controls when
    11·1 answer
  • using C++ to sort user input. for example, user enter 25numbers and sort them from small to big or big to small, cout thesamlles
    6·1 answer
  • In our discussion of Computer Hardware, we talked about three essential hardware components that are there inside every computer
    14·1 answer
  • Explain what led to the invention of lasers
    7·1 answer
  • What is the full form of RPM in computer ​
    10·2 answers
  • I'm not sure how to solve this problem
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!