1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Programming assignment question (Java)

  1. Aug 15, 2014 #1
    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.

    Link: http://poj.org/problem?id=1005

    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. jcsd
  3. Aug 15, 2014 #2

    ShayanJ

    User Avatar
    Gold Member

    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 [itex] R_i [/itex], then, for the change of the semicircle's area during a year, we have [itex] \Delta A=\frac \pi 2 (R_{i+1}^2-R_i^2) [/itex]. But we know that [itex] \Delta A=50 \ miles^2/year [/itex] so we can find [itex] R_{i+1} [/itex] in terms of [itex] R_i [/itex] which enables us to check whether a given point lies inside the semicircle or not.
     
  4. Aug 15, 2014 #3
    So I should look analyze the change in radius and use that to figure out if the point is in the semi-circle right?
     
  5. Aug 16, 2014 #4

    ShayanJ

    User Avatar
    Gold Member

    Right!
     
  6. Aug 16, 2014 #5
    Thanks!
     
  7. Aug 17, 2014 #6
    (R^2i+1−R^2i) seems to be a constant rate of 31.85. However there is no relationship between Ri+1 and Ri.
     
  8. Aug 18, 2014 #7

    ShayanJ

    User Avatar
    Gold Member

    [itex] 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} [/itex]
     
  9. Aug 18, 2014 #8
    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?
     
  10. Aug 19, 2014 #9

    Mark44

    Staff: Mentor

    Why not take input as double, then you don't need to cast?
     
  11. Aug 23, 2014 #10
    I think the assignment asks for float input.
     
  12. Aug 23, 2014 #11

    Mark44

    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.
     
  13. Aug 23, 2014 #12
    Oh ok. Yea, I didn't read it properly. Thanks!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Programming assignment question (Java)
  1. Java programming (Replies: 4)

  2. Java program (Replies: 3)

Loading...