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
Shtirlitz [24]
3 years ago
5

Rideshare companies like Uber or Lyft track the x,y coordinates of drivers and customers on a map. If a customer requests a ride

, the company's app estimates the minutes until the nearest driver can arrive. Write a method that, given the x and y coordinates of a customer and the three nearest drivers, returns the estimated pickup time. Assume drivers can only drive in the x or y directions (not diagonal), and each mile takes 3.5 minutes to drive. All values are doubles; the coordinates of the user and of the drivers are stored as arrays of length 2. 289222.1780078.qx3zqy7
Computers and Technology
1 answer:
TiliK225 [7]3 years ago
7 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

 public static void main (String[]args){

   Scanner input = new Scanner(System.in);

   double user[] = new double[2];    double dr1[] = new double[2];

   double dr2[] = new double[2];    double dr3[] = new double[2];    

   System.out.print("Enter user coordinates: ");

   for(int i =0;i<2;i++){        user[i] = input.nextDouble();    }

   System.out.print("Enter driver 1 coordinates: ");

   for(int i =0;i<2;i++){        dr1[i] = input.nextDouble();    }

   System.out.print("Enter driver 2 coordinates: ");

   for(int i =0;i<2;i++){        dr2[i] = input.nextDouble();    }

   System.out.print("Enter driver 3 coordinates: ");

   for(int i =0;i<2;i++){        dr3[i] = input.nextDouble();    }

   double dr1dist = Math.abs(user[0] - dr1[0]) + Math.abs(user[1] - dr1[1]);

   double dr2dist = Math.abs(user[0] - dr2[0]) + Math.abs(user[1] - dr2[1]);

   double dr3dist = Math.abs(user[0] - dr3[0]) + Math.abs(user[1] - dr3[1]);

   System.out.println("Estimated pickup time of driver 1 "+(3.5 * dr1dist)+" minutes");

   System.out.println("Estimated pickup time of driver 2 "+(3.5 * dr2dist)+" minutes");

   System.out.println("Estimated pickup time of driver 3 "+(3.5 * dr3dist)+" minutes");

 }

}

Explanation:

The following array declarations are for the customer and the three drivers

<em>    double user[] = new double[2];    double dr1[] = new double[2];</em>

<em>    double dr2[] = new double[2];    double dr3[] = new double[2];    </em>

This prompts the user for the customer's coordinates

   System.out.print("Enter user coordinates: ");

This gets the customer's coordinate

   for(int i =0;i<2;i++){        user[i] = input.nextDouble();    }

This prompts the user for the driver 1 coordinates

   System.out.print("Enter driver 1 coordinates: ");

This gets the driver 1's coordinate

   for(int i =0;i<2;i++){        dr1[i] = input.nextDouble();    }

This prompts the user for the driver 2 coordinates

   System.out.print("Enter driver 2 coordinates: ");

This gets the driver 2's coordinate

   for(int i =0;i<2;i++){        dr2[i] = input.nextDouble();    }

This prompts the user for the driver 3 coordinates

   System.out.print("Enter driver 3 coordinates: ");

This gets the driver 3's coordinate

   for(int i =0;i<2;i++){        dr3[i] = input.nextDouble();    }

This calculates the distance between driver 1 and the customer

   double dr1dist = Math.abs(user[0] - dr1[0]) + Math.abs(user[1] - dr1[1]);

This calculates the distance between driver 2 and the customer

   double dr2dist = Math.abs(user[0] - dr2[0]) + Math.abs(user[1] - dr2[1]);

This calculates the distance between driver 3 and the customer

   double dr3dist = Math.abs(user[0] - dr3[0]) + Math.abs(user[1] - dr3[1]);

The following print statements print the estimated pickup time of each driver

<em>   System.out.println("Estimated pickup time of driver 1 "+(3.5 * dr1dist)+" minutes");</em>

<em>    System.out.println("Estimated pickup time of driver 2 "+(3.5 * dr2dist)+" minutes");</em>

<em>    System.out.println("Estimated pickup time of driver 3 "+(3.5 * dr3dist)+" minutes");</em>

You might be interested in
Which of the following is a high-speed network dedicated to storage that connects different kinds of storage devices, such as ta
Montano1993 [528]

Answer:

SAN

Explanation:

A Storage Area Network (SAN) is a high-speed sub network of shared storage devices. A SAN's architecture works in a way that makes all storage devices available to all servers on a LAN or WAN. As more storage devices are added to a SAN, they too will be accessible from any server in the larger network.

8 0
3 years ago
A(n) _________ Web page displays customized content in response to keyboard or mouse actions or based on information supplied di
RoseWind [281]

Answer:

dynamic

Explanation:

A dynamic web page serves out varied material to various visitors while keeping the same layout and appearance. These pages, which are often built in AJAX, ASP, or ASP.NET, require longer to render than plain static sites. They are commonly used to display data that updates regularly, such as weather forecast or market prices.

Dynamic web pages often incorporate software applications for various services and need server-side resources such as databases. A database enables the page builder to divide the design of the website from the content that will be presented to users. When they post material to the database, the website retrieves it in response to a user request.

5 0
2 years ago
Answer for a, b, and c
Darya [45]

The answer is a. im pretty positive but if im wrong super sorry

5 0
3 years ago
What are some of the challenges that could arise from setting up a file management system on a computer
Katarina [22]
<span>You could download some software that could mess up your whole computer.</span>
3 0
3 years ago
Which ribbon tab has the tool that lets you connect your text to a URL?
Serjik [45]

Answer: Insert

Explanation:

The Ribbon was introduced by Microsoft in 2017 and it's simply a user interface element that can be found below Quick Access Toolbar. The Ribbon consist of seven tabs which are:

• Home

• Insert

• Page layout

• References

• Mailing

• Review

• View.

The Ribbon tab that has the tool that lets you connect your text to a URL is the Insert tab.

In the Menu bar, the person should click on the Insert tab that us in the Links section. After that, click on the Hyperlink or the Link option, then in the Insert Hyperlink window, one can then type addr as of the web page that the person wants to connect the text to after which the leoen will then click OK.

5 0
3 years ago
Other questions:
  • Which is an example of an input device?
    15·2 answers
  • A ____ client locates all or most of the processing logic on the server.
    11·1 answer
  • Given the availability of an ofstream object named output, write the other statements necessary to write the string "3.14159" in
    8·1 answer
  • In a non-formatted/standard template, if the number 25 is converted to text format, the
    14·1 answer
  • Which is the shortest and simplest tax form? <br> 1040 long form <br> 1040EZ<br> 1040A<br> 140E
    14·2 answers
  • Which command compiles the Java source code file Welcome.java?
    11·1 answer
  • Briley has all the hardware she needs to construct a fully functional personal computer. She connects the various components and
    7·1 answer
  • 1) APPLICATION BASED QUESTION:-
    5·1 answer
  • i have been looking for like 20 mins now and cant find the answers to test 3 on edhesive. does anybody have an clue to where i c
    12·1 answer
  • MP3 BrainPoP Quiz
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!