Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do Programming Exercise from Chapter 4, but add a decision to handle the case where the line does not intersect the circle. Chapter 4, Exercise

Do Programming Exercise from Chapter 4, but add a decision to handle the case where the line does not intersect the circle.

Chapter 4, Exercise 7:

Write a program that computes the intersection of a circle with a horizontal line and displays the information textually and graphically.

Input: Radius of the circle and the y-intercept of the line. Prompt the user for these values.

Output: Draw a circle centered at (0,0) with the given radius in a window with coordinates running from (10,10) to (10,10).

Draw a horizontal line across the window with the given y-intercept.

Draw the two points of intersection in red.

Print out the x values of the points of intersection in the upper left-hand corner of the window.

Formula for the intersection values of x:

+ and - square root of r squared - y squared

where r is the radius and y is the y-intercept.

When the user clicks anywhere on the window, it should close.

image text in transcribedimage text in transcribedimage text in transcribed

I think the problem is somewhere in the "try" statement. I can not get the red dots to show along with the X intercept message when the line does interesect the circle. It still says "None" under X-intercept. Please help.

image text in transcribed

File Edit Format Run Options Window Help import math from graphics import * def main ): win - GraphWin ("Line Segment", 300,420) win.setCoords (-10,-14,10,14) win.setBackground ("lightgrey") textboxRectangle (Point (-10,14), Point (10,10)) textbox.setFill("skyblue") textbox.setWidth (O) textbox.draw (win) outputboxRectangle (Point (-10,-10), Point (10,-14)) outputbox.setFill ("skyblue") outputbox.setWidth (0) outputbox.draw (win) for i in range (1,20) Table -Line (Point (i-10,-10), Point (i-10,10)) Table.setFill ("grey") Table.draw (win) Table = Line (Point (-10, 1-10) , Point ( 10, 1-10) ) Table.setFill ("grey") Table.draw (win) xaxis = Line (Point (-10, 0) , Point (10,0)) xaxis.setWidth (2) xaxis.draw (win) yaxis = Line (Point (-10, 0) , Point (10,0)) yaxis.setWidth (2) yaxis.draw (win) File Edit Format Run Options Window Help import math from graphics import * def main ): win - GraphWin ("Line Segment", 300,420) win.setCoords (-10,-14,10,14) win.setBackground ("lightgrey") textboxRectangle (Point (-10,14), Point (10,10)) textbox.setFill("skyblue") textbox.setWidth (O) textbox.draw (win) outputboxRectangle (Point (-10,-10), Point (10,-14)) outputbox.setFill ("skyblue") outputbox.setWidth (0) outputbox.draw (win) for i in range (1,20) Table -Line (Point (i-10,-10), Point (i-10,10)) Table.setFill ("grey") Table.draw (win) Table = Line (Point (-10, 1-10) , Point ( 10, 1-10) ) Table.setFill ("grey") Table.draw (win) xaxis = Line (Point (-10, 0) , Point (10,0)) xaxis.setWidth (2) xaxis.draw (win) yaxis = Line (Point (-10, 0) , Point (10,0)) yaxis.setWidth (2) yaxis.draw (win)

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

Step: 3

blur-text-image

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions

Question

Recognize the four core purposes service environments fulfill.

Answered: 1 week ago

Question

Know the three main dimensions of the service environment.

Answered: 1 week ago