Question

: Design (pseudocode) and implement (source code) a program (name it Circles) to determine if a...

: Design (pseudocode) and implement (source code) a program (name it Circles) to determine if a circle is either completely inside, overlapping with, or completely outside another circler. The program asks the user to enter the center point (X1, Y1) and the radius (R1) for the first circle C1, and the center point (X2, Y2) and the radius (R2) for the second circle C2. The program then determines if the second circle C2 is either completely inside, or overlapping with, or completely outside the first circle C1. Hint: use the sum of R1 and R2 and the distance between the centers to solve the problem. Document your code, properly label the input prompts, and organize the outputs as shown in the following sample runs. Sample run 1: Circle 1 center is: (0,0) Circle 1 radius is: 6 Circle 2 center is: (1,1) Circle 2 radius is: 1 Judgment: Circle 2 is completely inside circle 1 Sample run 2: Circle 1 center is: (0,0) Circle 1 radius is: 2 Circle 2 center is: (7,7) Circle 2 radius is: 1 Judgment: Circle 2 is completely outside circle 1 Sample run 3: Circle 1 center is: (0,0) Circle 1 radius is: 3 Circle 2 center is: (2,2) Circle 2 radius is: 3 Judgment: Circle 2 is overlapping with circle 1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:-

The below is the required source code for the given problem

PSEUDOCODE:-

1.  Start
2.  Input x1, y1 and r1
3.  Input x2, y2 and r2
4.  d = sqrt((x1-x2)^2 + (y1-y2)^2)
5.  r = r1 + r2
6.  If d >= r
7.    Print "Circle 2 is completely outside circle 1"
8.  Else if d < r && (x1 + r1 > x2 + r2 && y1 + r1 > y2 + r2)
9.    Print "Circle 2 is completely inside circle 1"
10. Else
11.   Print "Circle 2 is overlapping with circle 1"
12. Stop

CODE:-

using System;

class Circles{
    public static void Main (string[] args) {
        string userInput;
        int x1, y1, r1;//Coordinate and radius of first circle
        int x2, y2, r2;//Coordinate and radius of second circle

        //Input details for circle 1
        Console.Write("Circle 1 center is:      ");
        userInput = Console.ReadLine();//Read coordinate of first circle
        Console.Write("Circle 1 radius is:      ");
        x1 = Convert.ToInt32(userInput[1]);
        y1 = Convert.ToInt32(userInput[3]);
        r1 = Convert.ToInt32(Console.ReadLine());//Read radius of first circle

        //Input details for circle 2
        Console.Write("Circle 2 center is:      ");
        userInput = Console.ReadLine();//Read coordinate of first circle
        Console.Write("Circle 2 radius is:      ");
        x2 = Convert.ToInt32(userInput[1]);
        y2 = Convert.ToInt32(userInput[3]);
        r2 = Convert.ToInt32(Console.ReadLine());//Read radius of first circle

        //Find distance between two centers
        double d = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        int r = r1 + r2;//Sum of radii

        if(d >= r){//circle 2 is outside circle 1
            Console.WriteLine("Judgement:               Circle 2 is completely outside circle 1");
        }
        else if(d < r && (x1 + r1 > x2 + r2 && y1 + r1 > y2 + r2)){//circle 2 is inside circle 1
            Console.WriteLine("Judgement:               Circle 2 is completely inside circle 1");
        }
        else{//circle 2 is overlapping with circle 1
            Console.WriteLine("Judgement:               Circle 2 is overlapping with circle 1");
        }
    }
}

If you find any difficulty with the code, please let know know I will try for any modification in the code. Hope this answer will helps you. If you have even any small doubt, please let me know by comments. I am there to help you. Please give Thumbs Up,Thank You!! All the best

Add a comment
Know the answer?
Add Answer to:
: Design (pseudocode) and implement (source code) a program (name it Circles) to determine if a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Pseudocode and PYTHON source code, thanks! Program 1: Design (pseudocode) and implement (source code) a class...

    Pseudocode and PYTHON source code, thanks! Program 1: Design (pseudocode) and implement (source code) a class (name it QuadraticEquation) that represents a quadratic equation of the form of ax2+ bx + x = 0. The class defines the following variables and methods: Private data field a, b, and c that represent three coefficients. A constructor for the arguments for a, b, and c. Three get methods for a, b, and c. Method getDiscriminant()returns the discriminant value, which is disc =...

  • PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name...

    PSEUDOCODE and PYTHON source code! Program 4: Design (pseudocode) and implement (source code) a program (name it MinMaxAvg) to determine the highest grade, lowest grade, and the average of all grades in a 4-by-4 two-dimensional arrays of integer grades (representing 4 students’ grades on 4 tests). The program main method populates the array (name it Grades) with random grades between 0 and 100 and then displays the grades as shown below. The main method then calls method minMaxAvg()that takes a...

  • PLEASE DO THE PSEUDOCODE FOR THE PROGRAM BELOW Program 3: Design (pseudocode) and implement (source code)...

    PLEASE DO THE PSEUDOCODE FOR THE PROGRAM BELOW Program 3: Design (pseudocode) and implement (source code) a program (name it DistinctValues) to display only district values in an array. The program main method defines a single-dimensional array of size 10 elements and prompts the user to enter 10 integers to initialize the array. The main method then calls method getValues() that takes an integer array and returns another single-dimensional array containing only distinct values in the original (passed) array. Document...

  • Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the...

    Design in Python (pseudocode) and implement (source code) a program (name it MyRectangle) that defines the following 3 methods: Method isValid() returns true if the sum of the width and height is greater than 30 Method Area() returns the area of the rectangle if it is a valid rectangle Method Perimeter() returns the perimeter of the rectangle if it is a valid rectangle The main method of MyRectangle prompts the user to enter the width and height of a rectangle...

  • Design (pseudocode) and implement (source code) a program (name it IncomeTax) that reads from the user...

    Design (pseudocode) and implement (source code) a program (name it IncomeTax) that reads from the user annual income, as integer value, and calculates the income tax based on the tax table below. Income Tax bracket Annual income <= $50,000 5% $50,000 < Annual income <= $200,000 10% $200,000 < Annual income <= $400,000 15% $400,000 < Annual income <= $900,000 25% $900,000 < Annual income 35% The program output should include the entered annual income followed by the applied tax...

  • Program 5: Design (pseudocode) and implement (source code) a program (name it Weekl yHours) to compute...

    Program 5: Design (pseudocode) and implement (source code) a program (name it Weekl yHours) to compute the total weekly hours for 3 employees. The program main method defines a two-dimensional array of size 3x7 to store employers' daily hours for the week. Each row represents one employee and each column represent one day of the week such that column 0 designates Monday, column 1 designates Tuesday, etc. The program main method populates the array with random numbers between 0 and...

  • PLEASE DO THIS IN JAVA!Design (pseudocode) and implement (source code) a program (name it PhoneBill) that...

    PLEASE DO THIS IN JAVA!Design (pseudocode) and implement (source code) a program (name it PhoneBill) that calculates the bill for a cellular telephone company. The company offers two types of service: regular service and premium service. The rates vary depending on the type of service. The rates are computed as follows: Regular service: $15.00 fee covering first 50 minutes. Charges for over 50 minutes are computed at the rate of $0.50 per minute. Premium service: $25.00 fee plus: a. For...

  • IN PYTHON the original problem was Design (pseudocode) and implement (source code) a program (name it...

    IN PYTHON the original problem was Design (pseudocode) and implement (source code) a program (name it WeeklyHours) to compute the total weekly hours for 3 employees. The program main method defines a two-dimensional array of size 3x7 to store employers’ daily hours for the week. Each row represents one employee and each column represent one day of the week such that column 0 designates Monday, column 1 designates Tuesday, etc. The program main method populates the array with random numbers...

  • PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it...

    PLEASE DO IN PYTHON Program 2: Design (pseudocode) and implement (source code) a program (name it FeetMeters) to display a conversion tables for feet and meter as show below. Document your code and properly. Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574 The program defines the following methods: Method feetToMeter() converts from...

  • IN PYTHON WITHOUT USING: .APPEND/ .SORT/ INSERT / .SPLIT Program 1: Design (pseudocode) and implement (source...

    IN PYTHON WITHOUT USING: .APPEND/ .SORT/ INSERT / .SPLIT Program 1: Design (pseudocode) and implement (source code) a program (name it Occurrences) to determine whether two two-dimensional arrays are equivalent or not. Two arrays are equivalent if they contain the same values in any order. The program main method defines two two-dimensional array of size 3-by-3 of type integer, and prompts the user to enter integer values to initialize the arrays. The main method calls method isEquivalent()that takes two two-dimensional...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT