even more circles

even more circles

Write an application that compares two circle objects.
? You need to include a new method equals(Circle c) in Circle class. The method compares the radiuses.
? The program reads two radiuses from the user
? The program then creates two circle objects
? and compares them by using equals() method.
Hint. if (circle1.equals(circle2)) ...
? The comparison result is printed.
View Answers

August 17, 2010 at 3:35 PM

Hi Friend,

Try the following code:

import java.util.*;
class Circle{

double radius;
Circle(){
}
Circle(double radius){
this.radius=radius;
}
public double getRadius(){
return radius;
}
public boolean equals(Circle c) {
if (c.getRadius() == this.getRadius()){
return true;
}
else{
return false;
}
}

}
public class CircleApplication
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter Radius1: ");
double r1=input.nextDouble();
Circle c1=new Circle(r1);
System.out.print("Enter Radius2: ");
double r2=input.nextDouble();
Circle c2=new Circle(r2);
boolean result=c1.equals(c2);
System.out.println(result);
}
}

Thanks









Related Tutorials/Questions & Answers:
even more circles - Java Beginners
even more circles  Write an application that compares two circle objects. ? You need to include a new method equals(Circle c) in Circle class. The method compares the radiuses. ? The program reads two radiuses from the user
more circles - Java Beginners
more circles  Write an application that uses Circle class you created in the previous assignment. ? The program includes a static method createCircle() that o reads a radius of a circle from the user o creates a circle object
Advertisements
ModuleNotFoundError: No module named 'even-more-itertools'
ModuleNotFoundError: No module named 'even-more-itertools'  Hi, My... named 'even-more-itertools' How to remove the ModuleNotFoundError: No module named 'even-more-itertools' error? Thanks   Hi
Attaching circles
Attaching circles  How to attach circles with a distance joints
Circles and Triangles
Circles and Triangles  How can I draw the triangle inside the ellipse with 3 mouse clicked(or how can i do an outside triangle circle with 3 mouse clicked)?? This is my code for triangle with 3 mouse Clicked but I don't know how
ModuleNotFoundError: No module named 'Circles'
ModuleNotFoundError: No module named 'Circles'  Hi, My Python... 'Circles' How to remove the ModuleNotFoundError: No module named 'Circles... to install padas library. You can install Circles python with following command
ModuleNotFoundError: No module named 'Circles'
ModuleNotFoundError: No module named 'Circles'  Hi, My Python... 'Circles' How to remove the ModuleNotFoundError: No module named 'Circles... to install padas library. You can install Circles python with following command
ModuleNotFoundError: No module named 'Circles'
ModuleNotFoundError: No module named 'Circles'  Hi, My Python... 'Circles' How to remove the ModuleNotFoundError: No module named 'Circles... to install padas library. You can install Circles python with following command
ModuleNotFoundError: No module named 'Circles'
ModuleNotFoundError: No module named 'Circles'  Hi, My Python... 'Circles' How to remove the ModuleNotFoundError: No module named 'Circles... to install padas library. You can install Circles python with following command
how to draw lines,circles, rectangles on JSP.
how to draw lines,circles, rectangles on JSP.  how to draw lines,circles, rectangles on JSP. Kindly provide solutions asap
odd and even
odd and even  how can i make a program of even and odd using case statement?   Hi Friend, Try the following code:ADS_TO_REPLACE_1 import...{ System.out.println(); System.out.println("1 Display Even
Even and odd functions in java
Even and odd functions in java  Even and odd functions in java  ...); int number; System.out.println("Input any number to check even...) { if (n % 2 == 0){ System.out.println("Your number " + n + " is even
Check even or odd number.
Check even or odd number.  How to check given number is even or odd?   Simple if it is devided by 2 it is even and if not if is Odd  ...){ System.out.println("Number is Even"); } else
ModuleNotFoundError: No module named 'even_detector'
ModuleNotFoundError: No module named 'even_detector'  Hi, My... 'even_detector' How to remove the ModuleNotFoundError: No module named 'even_detector' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'even_detector'
ModuleNotFoundError: No module named 'even_detector'  Hi, My... 'even_detector' How to remove the ModuleNotFoundError: No module named 'even_detector' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'even-tester'
ModuleNotFoundError: No module named 'even-tester'  Hi, My Python... 'even-tester' How to remove the ModuleNotFoundError: No module named 'even-tester' error? Thanks   Hi, In your python environment
JSTL - check odd/even number - JSP-Servlet
JSTL - check odd/even number  How do i create a JSTL program to generate random numbers and to check whether they are odd/even and print "this is an even (odd) number and it is in between so and so number? e.g. the random number
EVEN NUMBERS - Java Interview Questions
EVEN NUMBERS  i want program of even numbers?i want source code plz reply?  Hi Friend, Try the following code: class EvenNumbers... counter = 0; System.out.println("Even Numbers are:" ); for (int i
how to draw lines,circles, rectangles on JSP (using Java Graphics)
how to draw lines,circles, rectangles on JSP (using Java Graphics)  how to draw lines,circles, rectangles on JSP (using Java Graphics)   Hello Anuj Try the Following Code :ADS_TO_REPLACE_1 image.jsp <%@ page
how to draw multilple circles in a circular form and connect them with lines - Java Beginners
how to draw multilple circles in a circular form and connect them with lines  Hi, Can anyone explains me , how to draw multiple circles using a single applet or swings in a circular form and connect them with lines. It should
circles - Java Beginners
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
ModuleNotFoundError: No module named 'does-this-even-work-anymore'
ModuleNotFoundError: No module named 'does-this-even-work-anymore'  ...: No module named 'does-this-even-work-anymore' How to remove the ModuleNotFoundError: No module named 'does-this-even-work-anymore' error? Thanks
Listing all even numbers between two numbers
Listing all even numbers between two numbers  Hi, How to write code to list all the even numbers between two given numbers? Thanks   Hi, You function will take 2 numbers and the find the even numbers between
How to list even numbers between 1 and 100?
How to list even numbers between 1 and 100?  Hi, I Java to check if a number is even? How to list even numbers between 1 and 100? Thanks   Hi, If number is divisible by 2 then its even number. Suppose you have
print the even numbers between the range 100-200
print the even numbers between the range 100-200  Q ?write an application that print out the even numbers between the range 100-200 ? 1- which aer... prints out the even numbers between the range of 100 and 200 and then determine
log4j is not logging even under src path
log4j is not logging even under src path  We are working with struts application and using log4j.properties file , it is placed under WEB-INF/classes and we have referenced log4j-1.2.8.jar in classpath file even after
Odd Even Transposition Sort In Java
Odd Even Transposition Sort In Java   ... In this example we are going to sort integer values of an array using odd even transposition sort. Odd even transposition sort is a parallel sorting algorithm. Odd Even
Java write even numbers to file
Java write even numbers to file In this section, you will learn how to write the even numbers to file. By using the PrintWriter class, you can write any type... leaving 0 remainder, then it should be an even number and stored in the file. We
Download all dependencies with yumdownloader, even if already installed?
Download all dependencies with yumdownloader, even if already installed?  Hi, I want to download all the dependencies with yumdownload even... for Download all dependencies with yumdownloader, even if already installed? Thanks  
PRIME AND EVEN AND ODD - Java Interview Questions
PRIME AND EVEN AND ODD  how to write prime numbers?i want source code? how to write even numbers? i want source code? how to write odd numbers ?i... + " "; } } } System.out.println(primeNo); } } 2) Following code displays Even and Odd numbers
NoSuchMethodException even if method defined - Java Beginners
NoSuchMethodException even if method defined  Hi I am loading a class (Student) dynamically from a jar (samplejar.jar) file using URLClassLoader. Next thing when I want to access method or constructor of the previously loaded
Display Hello even before main get executed??
Display Hello even before main get executed??  I have a class (main method) as follow.....As I know this can be done using static method, but Q is how? **class Hello{ public static void main(String[] args
ModuleNotFoundError: No module named 'more'
ModuleNotFoundError: No module named 'more'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'more' How to remove the ModuleNotFoundError: No module named 'more' error
UITableview show more
UITableview show more  How to fetch more records from the sql database in UITableview using show more option when there is a large amount of data? Thanks
Is R or Python more popular?
Is R or Python more popular?  Hi, I am beginner in Data Science... or Python more popular? Try to provide me good examples or tutorials links so that I can learn the topic "Is R or Python more popular?". Also tell me
SEND + MORE = MONEY
SEND + MORE = MONEY  Problem Description Write a program to solve... of magic formula is no more than 3, the number of digits of every number is no more... by exactly one space. Example Sample Input: 1 SEND + MORE = MONEY Sample Output
Which method is more efficient?
Which method is more efficient?  I'm faced with initializing a bunch of text fields in java. The problem is that the number of text fields is quite large, so i thought of putting them into an array and using a loop to initialize
more code help
more code help  Instructions: Write a program to translate a message from English to Morse code. Using a simple text editor like Windows Notepad, create a text file with all of the Morse code combinations for the letters
load more with jquery
load more with jquery  i am using jquery to loadmore "posts" from my... box its is going to display php posts and after that when i click on load more...); $('#loadmorebutton').html('Load More
write an application that print out the even numbers between the range 100-200
write an application that print out the even numbers between the range 100-200   write an application that print out the even numbers between... and determine the even numbers between them. class EvenNumbers { public static
ModuleNotFoundError: No module named 'even-better-setuptools-git-version'
ModuleNotFoundError: No module named 'even-better-setuptools-git-version' ...: ModuleNotFoundError: No module named 'even-better-setuptools-git-version' How to remove the ModuleNotFoundError: No module named 'even-better-setuptools-git-version
ModuleNotFoundError: No module named 'even-better-setuptools-git-version'
ModuleNotFoundError: No module named 'even-better-setuptools-git-version' ...: ModuleNotFoundError: No module named 'even-better-setuptools-git-version' How to remove the ModuleNotFoundError: No module named 'even-better-setuptools-git-version
Check whether highest number is even or odd
Check whether highest number is even or odd In this section, you will learn... it is odd or even. For this, we have taken two integer variables num1 and num2... that if the highest number is totally divided by 2,then it is even, otherwise
Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum separately. To do this, first of all, we have found all the even and odd numbers from 1
in this coding even backspace key and enter key should accept....
in this coding even backspace key and enter key should accept....   in this coding even backspace key and enter key should accept....plez help me and make changes to which it accept backspace and enter key ....plez plez plez its
more Submit buttons in the same form
more Submit buttons in the same form  Can I have two or more Submit buttons in the same form
Two or more actions in the same form
Two or more actions in the same form  Can I have two or more actions in the same form
How does this example work even if no oracle to be used and only access is available?
How does this example work even if no oracle to be used and only access...(); rs = stmt.executeQuery(searchQuery); boolean more... if (!more) { System.out.println("Sorry, you are not a registered
ModuleNotFoundError: No module named 'more-argparse'
ModuleNotFoundError: No module named 'more-argparse'  Hi, My... 'more-argparse' How to remove the ModuleNotFoundError: No module named 'more-argparse' error? Thanks   Hi, In your python

Ads