Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

John is given 2 square tiles, initially both of whose sides have length l placed in an x - y plane. Initially, the bottom left

John is given 2 square tiles, initially both of whose sides have length l placed in an x - y plane. Initially, the bottom left corners of each square are at the origin and their sides are parallel to the axes.
At t =0, both squares start moving along line y = x (along the positive x and y) with velocities s1 and s2.
For each querydetermine the time at which the overlapping area of tiles is equal to the query value, queries[i].
Note: Assume all distances are in meters, time in seconds and velocities in meters per second.
This squares are going the same direction x=y line.
Function Description:
Complete the movingTiles function in java below.
movingTiles has the following parameter(s):
int l: side length for the squares.
int s1: velocity of square 1.
int s2: velocity of square 2.
int queries[q]: the array of queries.
Returns:
int: an array of answers to the queries, in order. Each answer will be considered correct if it is at most 0.0001 away from the true answer.
Input Format:
First line contains integers l, s1, s2.
The next line contains q, the number of queries.
Each of the next q lines consists of one integer queries[i] in one line.
Sample Input
1012
2
50
100
Sample Output
4.1421
0.0000
Explanation
For the first case, note that the answer is around 4.1421356237..., so any of following will be accepted:
4.1421356237
4.14214
4.14215000
4.1421
4.1422

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions