# Programming assignment question (Java)

1. Aug 15, 2014

### kevinshen18

I'm not sure if I came to the right place/forum to ask this question, but I have a programming assignment and I need help on one of the question. It's part of the Peking University's online judge questions. It shouldn't be hard for people who understand it.

The question is unclear and confusing.
I don't understand the problem. The lost land forms a semi-circle, but I don't know if it increasing and it doesn't specify what rate. Is the semi-circle increasing at a specific rate? I understand the input and output part, but how am I supposed to calculate if the points are in the semi-circle without knowing it's growth rate?

I don't have any code as I haven't tried it yet because I don't understand.

I feel like I'm missing something.

2. Aug 15, 2014

### ShayanJ

Its simple. You should model the growth of that semicircle and check in what year it will contain the point in question. The important point is that if the radius of the semicircle at year i is $R_i$, then, for the change of the semicircle's area during a year, we have $\Delta A=\frac \pi 2 (R_{i+1}^2-R_i^2)$. But we know that $\Delta A=50 \ miles^2/year$ so we can find $R_{i+1}$ in terms of $R_i$ which enables us to check whether a given point lies inside the semicircle or not.

3. Aug 15, 2014

### kevinshen18

So I should look analyze the change in radius and use that to figure out if the point is in the semi-circle right?

4. Aug 16, 2014

### ShayanJ

Right!

5. Aug 16, 2014

### kevinshen18

Thanks!

6. Aug 17, 2014

### kevinshen18

(R^2i+1−R^2i) seems to be a constant rate of 31.85. However there is no relationship between Ri+1 and Ri.

7. Aug 18, 2014

### ShayanJ

$R_{i+1}^2-R_i^2=\frac{2\Delta A}{\pi} \Rightarrow R_{i+1}=\sqrt{\frac{2\Delta A}{\pi}+R_i^2}$

8. Aug 18, 2014

### kevinshen18

If the input is going to be floats and Ri+1 is a double then do I have to cast, if I am to make any calculations with those two?

9. Aug 19, 2014

### Staff: Mentor

Why not take input as double, then you don't need to cast?

10. Aug 23, 2014

### kevinshen18

I think the assignment asks for float input.

11. Aug 23, 2014

### Staff: Mentor

No, it doesn't. Quoting from what you posted, it says "These will be floating point numbers measured in miles." Both float and double are floating point types, as opposed to the integral types short, int, long, and the various signed or unsigned versions of these.

12. Aug 23, 2014

### kevinshen18

Oh ok. Yea, I didn't read it properly. Thanks!