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
katrin2010 [14]
3 years ago
11

Write code that will copy the contents of the file into an array. You can assume that the file will only have 5 data values

Computers and Technology
1 answer:
SpyIntel [72]3 years ago
8 0

Answer:

Explanation:

The following code is written in Java. It is a function that reads the file in the URL that is given in the parameter. It then places the file into a String and assumes that each element is separated by a space (" "). It then loops through that string adding each element into the created local ArrayList. Finally, It prints the contents of the ArrayList and returns the ArrayList.

public static ArrayList<String> toArray (String file) throws IOException {

               ArrayList<String> myArr = new ArrayList<>();

               BufferedReader reader = new BufferedReader(new FileReader(file));

               String readFile = reader.readLine();

               reader.close();

               for (int x = 0; x < readFile.length(); x++) {

                       int start = 0;

                       if (readFile.charAt(x) == ' ') {

                               myArr.add(readFile.substring(start,x));

                               start = x + 1;

                       }

               }

               for (String x : myArr) {

                       System.out.println(x);

               }

               

               return myArr;

       }

You might be interested in
DJ Davon is making a playlist for an internet radio show; he is trying to decide what 1212 songs to play and in what order they
Alja [10]

There are some typos in this question as the numbers become too large and lead to undefined during calculations.

so the correct data is:

Songs = 12

Rock = 15

Blues = 20

Disco = 15

The answer & explanation for this question is given in the attachment below.

4 0
3 years ago
Write a function DrivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar
stira [4]

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// function to calculate cost

double DrivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon){

  double cost;

  //Expression to compute cost

  cost = drivenMiles / milesPerGallon * dollarsPerGallon;

  return cost;

}

// main function

int main()

{

   double drivenMiles, milesPerGallon, dollarsPerGallon;

  //initialise the variables

  drivenMiles = 50;

  milesPerGallon = 20.0;

  dollarsPerGallon = 3.1599;

  //Call function

  double cost = DrivingCost(drivenMiles,milesPerGallon,dollarsPerGallon);

  //Display result

  cout<<"Driven miles : "<<drivenMiles<<endl;

  cout<<"Miles per Gallon : "<<milesPerGallon<<endl;

  cout<<"Dollars per Gallon : "<<dollarsPerGallon<<endl;

  cout << fixed << setprecision(2);

  cout<<"The total driving cost : "<<cost ;

  return 0;

}

Explanation:

Declare and initialize drivenMiles with 50, milesPerGallon with 20.0 and dollarsPerGallon with 3.1599.Call the function DrivingCost() with these parameters,This will calculate the cost and return the value.Print the result after getting the cost.Similarly we can calculate cost for drivenMiles equals to 10 and 400 miles also.

Output:

Driven miles : 50

Miles per Gallon : 20

Dollars per Gallon : 3.1599

The total driving cost : 7.90

5 0
3 years ago
Which osi layer is responsible for combining bits into bytes and bytes into frames?
Nastasia [14]
If you are breaking the computer down try in software it does change after a while
3 0
3 years ago
Which Internet connection can have speeds around 1 Gbps?<br> Cable<br> DSL<br> Fiber<br> Satellite
Alexus [3.1K]
<h2>Answer:</h2>

<u>Fiber</u> Internet connection has speeds around 1 Gbps.

<h2></h2><h2>Explanation:</h2>

Fiber Internet connection is the modern way of transmitting and receiving data. As obvious from the name Optical Fiber consists of thin fibers that are extremely thin (as a human hair). They transmit data with the beam of light that make this transmission speedy as well as reliable. Therefore they provide  the download speed ranging from 25 Mbps to 1 Gbps.

Fiber Internet connection is considered best for the small businesses as it provides high bandwidth for transmission.  The best part of this connection is that it is made of glass and plastic that  do not conduct heat or electricity that means the fiber is safe from the damages as well.

<h3>I hope it will help you! </h3>
5 0
4 years ago
Chris wants to view a travel blog her friend just created. Which tool will she use?
wolverine [178]

Answer:

Web browser

Explanation:

7 0
3 years ago
Other questions:
  • What is the definition of a command computer?
    15·1 answer
  • Please help I’ll give you 10 points
    8·2 answers
  • Help me out here pleaseeeee
    9·2 answers
  • Passwords are usually alphanumeric and usually cannot contain spaces or ________.
    10·2 answers
  • _____ selectors are used to select elements based on elements that are adjacent to them in the document hierarchy.
    9·1 answer
  • Place the steps in order for manually creating a New Contact Group
    10·2 answers
  • CorpServ is a small company with 14 client systems and a network printer. Because there are only a limited number of networked s
    13·1 answer
  • What is the difference between business strategies and business models?
    9·1 answer
  • (Brainliest!!)<br><br> How do i get rid of a headache?
    15·2 answers
  • A _____ is a specially formatted file that, once mounted, or connected to a virtual machine appear and operate pretty much ident
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!