Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment: Cell Wall In this assignment you will detect whether or not a particle lies inside, outside, or on a hypothetical circular cell wall. To

Assignment: Cell Wall

In this assignment you will detect whether or not a particle lies inside, outside, or on a hypothetical circular cell wall. To do this, you will need the radius of the circle and the (x,y) coordinate of the particle. Create the following menu:

 1) Enter coordinate of particle 2) Generate random particle 

Initialize the radius to a value of 10

If the user chooses 1:

Ask for an x

Ask for a y

Output "In", "On", or "Out" depending on where the coordinate is

If the user chooses 2:

generate a random number between 0 and 20 for each x and y

Seed your RNG in the beginning of the program with the number 2018 so your numbers match the tester

Note: the server builds your code on a 64-bit Linux machine, so your randoms might appear different than the server's. As long as you use the seed 2018 you will be fine.

output the coordinate as (x,y)

Output "In", "On", or "Out" depending on where the coordinate is

To determine In, On, or Out, use the following logic:The equation of a circle is x^2 + y^2 = r^2

Solving this equation for r, you get r = sqrt(x^2 + y^2)

since r = 10, this gives 10 = sqrt(x^2 + y^2)

if abs(sqrt(x^2 + y^2) - 10) < 0.01, we will consider x and y to be close enough to r and call that "On"

else if sqrt(x^2 + y^2) < 10, then it must be "In"

else it must be "Out". This last condition would be sqrt(x^2 + y^2) > 10, but we do not need to check for this since if it were not true then one of the earlier conditions would have been met.

Sample output:

1) Enter coordinate of particle 2) Generate random particle 1 x: 3 y: 4 In 
1) Enter coordinate of particle 2) Generate random particle 1 x: 0 y: 10 On 
1) Enter coordinate of particle 2) Generate random particle 1 x: 15 y: 15 Out 
1) Enter coordinate of particle 2) Generate random particle 2 (1,17) Out

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

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago