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
Is backing up computer files done on the hard drive?
8_murik_8 [283]
Yes but if the hard drive stops working you will lose your files so it's better to backup your files to a cloud like iCloud by Apple.
5 0
3 years ago
Read 2 more answers
Another one please help quick i got to go soon
astraxan [27]

Answer:

no

Explanation:

yellow: the last sentence in the text

blue: Queenies flowers reached for the sky

Personification means that you apply human characteristics to things that are not alive, like a flower smiling, a term used when people see a field of healthy flowers

7 0
2 years ago
Until 2015, each new Roblox user automatically had one friend. What was he called?
RUDIKE [14]

Until 2015, each new Roblox user automatically had one friend and the friend was called Builderman

Builderman is the friend that is provided automatically for all users until 2015

<h2>Further Explanation</h2>

The builderman welcomes each new Roblox user, send a message to them and automatically follows every user until when it was discontinued in 2014. The role of the Builderman was to introduce the game experience to each new Roblox user.

Roblox is an online game and serves as a platform where users can also create their own games. Roblox gives its users the platform to design their own games and allow its user to different kinds of games that are created by other users on the platform

Roblox hosts numerous games designed by its users and virtual worlds which covers different genres, such as traditional racing, obstacle courses and many more.

Roblox has millions of users worldwide, its monthly active users are over 100million. Roblox also allows its users to create virtual items for sale. This also implies, its users can create virtual items and sell them for other users

Roblox was founded by David Baszucki and Erik Cassel; it was released on September 1, 2006. It is a platform that allows single-player and multiplayer.

LEARN MORE:

  • Until 2015, each new Roblox user automatically had one friend. What was he called?  brainly.com/question/12694552
  • What is the programming language of Roblox called?  brainly.com/question/13166316

KEYWORDS:

  • roblox
  • builderman
  • friend
  • message
  • automatically
  • david baszucki
  • erik cassel
6 0
3 years ago
Read 2 more answers
The range of a finite nonempty set of $n$ real numbers $S$ is defined as the difference between the largest and smallest element
-Dominant- [34]

Answer: Hello your question is poorly written attached below is the well written question

answer:

a) Determine ( compute ) the difference between the max and minimum value. determine the Min and max values using 1.5n comparisons

  time efficiency = θ( n )

b) A(n-1) - A(0)

  time efficiency = θ( 1 )

Explanation:

a) An unsorted array

To find the maximum and minimum values scan the array of elements , then determine ( compute ) the difference between the max and minimum value. to determine the range. Alternatively determine the Min and max values using 1.5n comparisons

Algorithm's time efficiency = θ( n )

b) A sorted array

To determine the range, we will determine the difference between the first and last element i.e. A(n-1) - A(0)

time efficiency = θ( 1 )

7 0
2 years ago
The process of executing a program is also called ________.
irga5000 [103]
It is also called running it.  Hope this helps!!!
5 0
2 years ago
Other questions:
  • Aubrey didnt like to use graphics or images on her slides. She preferred to use only a title for her slides and bullet-poinged t
    14·2 answers
  • This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.
    14·2 answers
  • A signal has a spectrum from 0 to 145 Hz, as shown below. It is sampled at a rate of 295 Hz. Find the region of the baseband spe
    5·2 answers
  • What do level meters show?
    8·1 answer
  • Which one of the following items is an example of software?
    5·1 answer
  • Which of the following is an example of an output device
    13·1 answer
  • Write a SELECT statement that returns a single value that represents the sum of the largest unpaid invoices submitted by each ve
    5·1 answer
  • Choose the best type of loop for each situation.
    6·1 answer
  • Why is drive of value when pursuing a career in IT?
    14·1 answer
  • 3. Special keys labelled Fl to F12.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!