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

Answers

Answer 1

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

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

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

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

  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");


Related Questions

when the tv was created (year)

Answers

Answer:

1927

Explanation:

Answer:

1971 is the year

Understanding Join Types
Which join type will only include rows where the joined fields from both tables are equal?
O inner join
O left outer join
Oright inner join
O right outer join

Answers

Answer: inner join

Explanation:Edg. 2021

When developing an algorithm to solve a problem, which of these steps can help you design the solution for the problem?

Answers

Answer:

3 is the answer please mark me brainlist

Explanation:

ok

When determining the statement of purpose for a database design, what is the most important question to ask?
O Who will use the database?
O Should I use the Report Wizard?
O How many copies should I print?
O How many tables will be in the database?

Answers

Answer: A. Who will use the database?

Explanation:

When determining the statement of purpose for a database design,the most important question to ask is  Who will use the database?

What is the purpose of statement of purpose for a database ?

Statement of purpose in a data base is very essential to know more about the database, this is why it is important to ask the question Who will use the database?

This question help the programmer to know the kind of data that will be running at the database so as make sure the database serve the required purpose.

Therefore option A is correct.

Read more about database at:

https://brainly.com/question/518894

#SPJ9

Order the steps needed to design a relational database.
Identify the fields holding
Break down the data into
List the fields needed to
Identify the common fields
Distribute the fields into
stored data
smaller parts
gain information
for linking tables
tables by subject
We

Answers

Answer:

1. List the fields needed to gain information

2. Break down the date into smaller parts

3. identify the fields holding stored data

4.distribute the fields into tables by subject

5. identify the common fields for linking tables

Explanation:

edge 2021

The correct matching of the steps for a relational database are:

1. List the fields needed to gain information2. Break down the date into smaller parts

What is a Database?

This refers to the collection of data that is stored in a central system that can be easily retrieved at any time.

The other answers are:

3. identify the fields holding stored data4. distribute the fields into tables by subject5. identify the common fields for linking tables

Read more about databases here:

https://brainly.com/question/6344749

#SPJ2

A new version of quicksort has been suggested by Professor I. M. CRAZY called CRAZYSORT in which anadversary picks the splitter in Partition in the worst possible way to maximize the running time of CRAZYSORT, thatis, line 1 of Partition (see textbook) is determined by the adversary in constant timeO(1). What is the running time ofCRAZYSORT? Justify your answer.

Answers

Thiughutghuyhhugbjjuhbuyghuughh it’s d

Davos has been reading about encryption recently. He begins to wonder how anything can be secure if everyone is using the same set of algorithms. After all, anyone using the same algorithm would be able to decrypt anything that had been encrypted using that algorithm. Which of the following helps make the data unusable by anyone else using that same encryption scheme without having this information?
a. Algorithm
b. Cipher
c. Key
d. Block

Answers

Answer:

The correct answer is B. Cipher.

Explanation:

Cipher is a system of reversible transformations that depends on some secret parameter, called key, and is designed to ensure the secrecy of transmitted information.

The cipher can be a combination of conventional characters or an algorithm for converting ordinary numbers and letters. The process of making a message secret with a cipher is called encryption. An important parameter of any cipher is the key - a parameter of the cryptographic algorithm, which ensures the selection of one transformation from the set of transformations possible for this algorithm. In modern cryptography, it is assumed that all the secrecy of a cryptographic algorithm is concentrated in the key.

#Program to calculate statistics from student test scores. midterm_scores = [99.5, 78.25, 76, 58.5, 100, 87.5, 91, 68, 100] final_scores = [55, 62, 100, 98.75, 80, 76.5, 85.25] #Combine the scores into a single list all_scores = midterm_scores + final_scores num_midterm_scores = len(midterm_scores) num_final_scores = len(final_scores) print(num_midterm_scores, 'students took the midterm.') print(num_final_scores, 'students took the final.') #Calculate the number of students that took the midterm but not the final dropped_students = num_midterm_scores - num_final_scores print(dropped_students, 'students must have dropped the class.') lowest_final = min(final_scores) highest_final = max(final_scores) print('\nFinal scores ranged from', lowest_final, 'to', highest_final) # Calculate the average midterm and final scores # Hint: Sum the midterm scores and divide by number of midterm takers # Repeat for the final

Answers

Answer:

try this

Explanation:

#Python program for calculating avg

#Given data

m1 = [99.5, 78.25, 76, 58.5, 100, 87.5, 91, 68, 100]

f1 = [55, 62, 100, 98.75, 80, 85.25]

#combine scores

all_scores = m1 + f1

#number of m1 and f1

num_midterm = len(m1)

num_final = len(f1)

#find avg of scores

avg_midterm = sum(m1) / num_midterm

avg_final = sum(f1) / num_final

#print the avg

print("Average of the m1 score:",round(avg_midterm,2))

print("Average of the f1 score:",round(avg_final,2))

What are 3 data Gathering method that you find effective in creating interactive design for product interface and justify your answer?

Answers

Answer:

In other words, you conducted the four fundamental activities that make up the interaction design process – establishing requirements, designing alternatives, prototyping designs, and evaluating prototypes.

Explanation:

How I did it. Part 4

Answers

Answer:

What are you asking for in this problem?

Explanation:

Who is MrBeast?
Answer the question correctly and get 10 points!

Answers

Answer: MrBeast is a y0utuber who has lots of money

Explanation:

Answer:

He is a You tuber who likes to donate do stunts and best of all spend money.

It's like he never runs out of money.

Explanation:

What characteristics should be determined to design a relational database? Check all that apply.
the fields needed
the tables needed
the keys and relationships
the purpose of the database
all of the tables in the database
all of the records in the database
the queries, forms, and reports to generate

Answers

Answer: 1,2,3,4,7

Just took it (:

Which of the following is MOST likely to be an outcome of the digital divide?

Answers

B, people from some racial of ethnic groups have unequal access to computing technology

First one who answers gets brainiest

Answers

Answer:

thank for the point anyway

What is Machine Learning (ML)?

Answers

Answer:

Explanation:

Machine learning is a branch of artificial intelligence (AI) and computer science which focuses on the use of data and algorithms to imitate the way that humans learn, gradually improving its accuracy.

Answer:

Machine learning is a type of learning that makes learning easy and faster with the help of electrical devices such as mobile phones,laptops etc

Explanation:

This enable the user to work faster and easily with no stress at all

Write a function template that accepts an argument and returns its absolute value. The absolute value of a number is its value with no sign. For example, the absolute value of -5 is 5, and the absolute value of 2 is 2. Test the template in a simple driver program being sure to send the template short, int, double, float, and long data values.

Answers

Answer:

The function in Java is as follows:

public static double func(double num){

       num = Math.abs(num);

       return num;

   }

Explanation:

This defines the function

public static double func(double num){

This determines the absolute function of num

       num = Math.abs(num);

This returns the calculated absolute value

       return num;

   }

For this assignment your are to implement the Pet Class described in Programming Exercise 1, starting on page 494 in our textbook. Additionally your program will allow users to enter the pet's information until the user enters in the string "quit". Once the user enters quit the program will print out a summary of all the information that has been entered. Your program should not assume any maximum number of pets that can be added. Items in blue designate output. Items in red designate computer input. Example Test Case: Enter name, type and age of your pet: Name: Momo Type: Bird Age: 33 Enter "quit" to stop entering. Anything else to continue. a Enter name, type and age of your pet: Name: Pooh Type: Dog Age: 8 Enter "quit" to stop entering. Anything else to continue. quit SUMMARY: Name: Momo, Type: Bird, Age: 33. Name: Pooh, Type: Dog, Age: 8.

Answers

Answer:

ohhhvhhffifyuddfuiicfdguc

New cars use embedded computers to make driving safer

Answers

Answer:

true.......................

New cars use embedded computers to make driving safer. The given statement is true.

What is RAM?

The word RAM stands for random-access memory and it is known as memory of short term where data is stored and as required by the processor. This is not there to deal with long term data and it is working after the computer turned off.

Generally, there are three types of RAM and these are SRAM, ECC, and DRAM. The SRAM stands for static random memory, and DRAM stands for dynamic access memory.

CPU stands for central processing unit and commonly it is known as brain of the computer, the main function of CPU is to control the function of the computer or system and it gives command to the parts of computer.

Therefore, New cars use embedded computers to make driving safer. The given statement is true.

Learn more about RAM and CPU here:

brainly.com/question/21252547

#SPJ2

What does the following code print?
// upload only .txt file ***************************************************** public class { public static void main(String[] args) { int x=5 ,y = 10; if (x>5 && y>=2) System.out.println("Class 1"); else if (x<14 || y>5) System.out.println(" Class 2"); else System.out.println(" Class 3"); }// end of main } // end of class.

Answers

Answer:

Error - At least one public class is required in main file

if you change it too:

public class main{

   public static void main(String[] args) {

       int x=5 ,y = 10;

       if (x>5 && y>=2) System.out.println("Class 1");

       else if (x<14 || y>5) System.out.println(" Class 2");

       else System.out.println(" Class 3"); }

       // end of main

       }

       // end of class.

than it will say Class 2.

Explanation:

In numerical methods, one source of error occurs when we use an approximation for a mathematical expression that would otherwise be too costly to compute in terms of run-time or memory resources. One routine example is the approximation of infinite series by a finite series that mostly captures the important behavior of the infinite series.
In this problem you will implement an approximation to the exp(x) as represented by the following infinite series,
exp(x) = Infinity n= 0 xn/xn!
Your approximation will be a truncated finite series with N + 1 terms,
exp(x, N) = Infinityn n = 0 xn/xn!
For the first part of this problem, you are given a random real number x and will investigate how well a finite series expansion for exp(x) approximates the infinite series.
Compute exp(x) using a finite series approximation with N E [0, 9] N (i.e. is an integer).
Save the 10 floating point values from your approximation in a numpy array named exp_approx. exp_approx should be of shape (10,) and should be ordered with increasing N (i.e. the first entry of exp_approx should correspond to exp(x, N) when N = 0 and the last entry when N = 9).

Answers

Answer:

The function in Python is as follows:

import math

import numpy as np    

def exp(x):

   mylist = []

   for n in range(10):

       num = (x**n)/(math.factorial(n))

       mylist.append([num])

   exp_approx = np.asarray(mylist)

   sum = 0

   for num in exp_approx:

       sum+=num

   return sum

Explanation:

The imports the python math module

import math

The imports the python numpy module

import numpy as np    

The function begins here

def exp(x):

This creates an empty list

   mylist = []

This iterates from 0 to 9

   for n in range(10):

This calculates each term of the series

       num = (x**n)/(math.factorial(n))

This appends the term to list, mylist

       mylist.append([num])

This appends all elements of mylist to numpy array, exp_approx

   exp_approx = np.asarray(mylist)

This initializes the sum of the series to 0

   sum = 0

This iterates through exp_approx

   for num in exp_approx:

This adds all terms of the series

       sum+=num

This returns the calculated sum

   return sum

name the reactants in the equation P+O​

Answers

Reactants are the factors that yield the subdivision of a molecule. Products are the result of this division. In other words, reactants are left of the equation and products are on the right. P+O are reactants, but the product is not shown.

Why is it important to isolate evidence-containing devices from the internet?
To save the battery
To hide their location
Devices can be remotely locked or wiped if connected
It is not important to isolate the devices

Answers

Answer:

C.

Devices can be remotely locked or wiped if connected

Explanation:

Write a test program that prompts the user to enter the number of the items and weight for each item and the weight capacity of the bag, and displays the maximum total weight of the items that can be placed in the bag. Here is a sample run:

Answers

Answer:

The program in Python is as follows:

n = int(input("Number of weights: "))

weights= []

for i in range(n):

   inp = float(input("Weight: "))

   weights.append(inp)

capacity = float(input("Capacity: "))

possible_weights = []

for i in range(n):

   for j in range(i,n):

       if capacity >= weights[i] + weights[j]:

           possible_weights.append(weights[i] + weights[j])

print("Maximum capacity is: ",max(possible_weights))

Explanation:

This gets the number of weights from the user

n = int(input("Number of weights: "))

This initializes the weights (as a list)

weights= []

This iteration gets all weights from the user

for i in range(n):

   inp = float(input("Weight: "))

   weights.append(inp)

This gets the weight capacity

capacity = float(input("Capacity: "))

This initializes the possible weights capacity (as a list)

possible_weights = []

This iterates through the weights list

for i in range(n):

   for j in range(i,n):

This gets all possible weights that can be carried by the bag

       if capacity >= weights[i] + weights[j]:

           possible_weights.append(weights[i] + weights[j])

This prints the maximum of all possible weights

print("Maximum capacity is: ",max(possible_weights))

The first real web browsers that looked even somewhat like the web we know today were not created until which year?
O 1996
1994
O 1997
O 1995

Answers

Answer:

1994 is the answer . make me brainlist

______allow you to select elements that are in a certain state, such as when the mouse if hovering over an element

Answers

Answer:

css.

Explanation:

Java 2D Drawing Application. The application will contain the following elements:
a) an Undo button to undo the last shape drawn.
b) a Clear button to clear all shapes from the drawing.
c) a combo box for selecting the shape to draw, a line, oval, or rectangle.
d) a checkbox which specifies if the shape should be filled or unfilled.
e) a checkbox to specify whether to paint using a gradient.
f) two JButtons that each show a JColorChooser dialog to allow the user to choose the first and second color in the gradient.
g) a text field for entering the Stroke width.
h) a text field for entering the Stroke dash length.
I) a checkbox for specifying whether to draw a dashed or solid line.
j) a JPanel on which the shapes are drawn.
k) a status bar JLabel at the bottom of the frame that displays the current location of the mouse on the draw panel.
If the user selects to draw with a gradient, set the Paint on the shape to be a gradient of the two colors chosen by the user. If the user does not chosen to draw with a gradient, the Paint with a solid color of the 1st Color.
Note: When dragging the mouse to create a new shape, the shape should be drawn as the mouse is dragged.

Answers

Answer:

sadness and depression is my answer

Explanation:

How might you use PowerPoint as a student, as an employee, or personally?

Answers

Answer: You can use a powerpoint as student for assignments, as an employee for presentations, and personally for taking notes.

Explanation:

Hey there!

Answer:

As a student, you might use PowerPoint to complete assignments and create presentations. When your teacher assigns an assignment that you need to share with the class, PowerPoint would be a good program to use.

As an employee, you can use PowerPoint to keep track of sales or data about your job. This way, you can easily show your boss what you have done over the past times you've been working. You can also advertise about your job depending on what your job is.

To use it personally, you can create photo montages of trips with a photo on each slide to share with friends. You can also keep track of chores or chore salaries.

The program PowerPoint can be used in so many ways for so many things, the rest is up to your imagination!

Hope this helps  :)

Suppose that a minus sign in the input indicates pop the stack and write the return value to standard output, and any other string indicates push the string onto the stack. Further suppose that following input is processed:
this parrot - wouldn't voom - if i put -- four thousand --- volts - through it -
What are the contents (top to bottom) left on the stack?
a. through wouldn't this.
b. this wouldn't through.
c. it through wouldn't.
d. it through volta.
e. volts through it.

Answers

Answer:

e. volts through it

Explanation:

volts through it

The contents (top to bottom) left on the stack is volts through it. Thus, option E is correct.

What is standard output?

When a computer program begins execution, standard streams are interconnected input and output channels of communication between the program and its surroundings. The three I/O connections are known as standard input (stdin), standard output (stdout), and standard error (stderr).

A negative sign in the input indicates that the stack should be popped, and the return value should be sent to standard output, whereas any other string means that the string should be pushed into the stack. Assume that the following input is processed: this parrot would not voom if I pushed — four thousand —- volts - through it.

The contents of the stack (from top to bottom) are volts via it. As a result, option E is correct.

Learn more about standard output here:

https://brainly.com/question/30054426

#SPJ5

Plz hurry it’s timed

Answers

A manufacturing company

Type the correct answer in the box. Spell all words correctly. Complete the sentence below that describes an open standard in video production. Today, video production has become digital, and all playback devices work on the open standard known as *blank* technology.​

Answers

Answer:

digital

Explanation:

Today, video production has become digital, and all playback devices work on the open standard known as digital technology.​

Other Questions
What is secondary succession PLEASE HELP MEWILL GIVE YOU BRAINLY TO WHOEVER ACTUALLY ANSWERS THIS Submit your first draft of your research paper that includes textual evidence and citations. Ensure that it has at least fiveparagraphs, with an introduction that demonstrates a clear thesis statement, body paragraphs, and a conclusionparagraph. Read the claim from the passage.Everyone knows reading is important because they read in school or at their job.Which statement best describes the claim?O A. questionable opinionOB.believable factOC.questionable factD.believable opinion Read the sentence below and answer the question that follows.A 47-year study by scientists in Great Britain revealed that the Parus major is laying eggs approximately two weeksearlier.Which led the Parus major to change its behavior?A) It is making the most of the availability of seasonal food.B) It is using leaves and other vegetation that is now sprouting earlier.C) It is arriving from migration earlier due to warmer weather.D) Its individual adaptability from year to year has been studied.E) Its nests need the camouflage offered by trees with leaves. g There are three alleles at a gene determining eye color in a population of wild cats, the B allele (brown eyes) is dominant to both the G allele (green eyes) and the Y allele (yellow eyes). The G allele is dominant to the Y allele. In a population of 1000, there are 100 yellow-eyed cats, 400 green-eyed cats, and 500 brown-eyed cats. What is the expected frequency of the Y allele 1. What is the distance bewteen the pair of points? (3,3) and (3,-2)2. Distance bewteen (-1,9) and (-8,9)? Please help work history edge Please select the word from the list that best fits the definitionEnglish playwright who wrote tragedies and comedies What role did geography have in Spartan militarism help me and ill give u points (math) 2 5/6 times 8 as a mixed number. Use the long division method to find the result when 6x3 + 10x + 7x + 2 isdivided by 3x + 2. 3.3 5.0 6.7 8.4 10.1Which one is it? Would an alkali metal make a good replacement for tin in a tin can? Explain. In triangle JKL, the length of side JK is 12 feet, and the length of side KL is 15 feet. Which of the following could be the length of side JL?A. 27 feetB. 30 feetC. 3 feetD. 4 feet 100 points Which detail best helps readers create a mental pictureof August?O Jack Will understands that August has smiled athim.O Jack Will looks August right in the face.O August's mouth goes straight across when hesmiles.O August has a feeling of almost-laughing, and thenhe smiles. Which measure of variability is the most appropriate for this set of values?13, 42, 104, 36, 28, 6, 17A. rangeB. interquartile rangeC. mean absolute deviationD. absolute deviationE. either interquartile range or mean absolute deviation How can you apply this approach to the classification of living things? Keisha works as a tutor for $13 an hour and as a waitress for $9 an hour. This month, she worked a combined total of 101 hours at her two jobs. Let t be the number of hours Keisha worked as a tutor this month. Write an expression for the combined total dollar amount she earned this month. The loudness, L, measured in decibels (Db), of a sound intensity, I, measured in watts per square meter, is defined as L = 10 log StartFraction I Over I 0 EndFraction, where I 0 = 10 Superscript negative 12 and is the least intense sound a human ear can hear. Jessica is listening to soft music at a sound intensity level of 10^-9 on her computer while she does her homework. Braylee is completing her homework while listening to very loud music at a sound intensity level of 10^-3 on her headphones. How many times louder is Braylees music than Jessicas? Name 4 other books authored by S.E. Hinton that were made into movies