Below is the solution:
concentricCircles.java:
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class concentricCircles {
public static void main(String[] args) {
Ovals ovalsPanel = new Ovals();
//call class to draw a circle
JFrame newFrame = new JFrame();
//create a frame
newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
newFrame.add(ovalsPanel);
newFrame.setSize(311, 333); //set
the size of the frame
newFrame.setVisible(true);
}
}
class Ovals extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getWidth();
//width
int height = getHeight();
//height
System.out.printf("Width is %d \t
and height is %d\n", width, height); //print the height and
width
// calculates the center of the
panel
int xPoint = width / 2;
int yPoint = height / 2;
drawCircles(g, 15, xPoint, yPoint);
//Recursive call
}
private void drawCircles(Graphics g, int n, int X,
int Y) {
if (n > 0) {
g.drawOval(X -
(n * 10), Y - (n * 10), (n * 20), (n * 20)); //draw a circle
drawCircles(g, n
- 1, X,Y); //call recurrsive function
}
}
}
output:
Asap Please write a Java program with comments Asap: Please write a java program with comments...
(In Java) Create an applet which draws two sets of concentric circles. Each set will use recursion: Start with a diameter of 255 for the outermost circle As each circle is drawn, use a color created via a constructor in the Color class: Color circleColor = new Color(diameter, diameter, diameter) ; Use recursion to draw the next inner circle: for one set of circles, decrease the diameter of each circle by 20 pixels for the other set of circles, decrease...
in java Write a program that uses recursion to find the largest number in an array. Declare and initialize an array of 10 different numbers.
PLEASE INCLUDE COMMENTS In java Create a Java Program Add the following comments at the beginning of the file: Your name. The name of the class(es) used in the program. The core concept (found below) for this lesson. The date the program was written. Include a recursive method separate from the main method that will add together all of the even numbers between and including 1 and the value the user supplies. For instance, if the user enters 10 then...
Can you write with comments please. Thank you. Write a Java Program that asks the user to enter the responses on the Console and write the responses to a text file called responses.txt (in the same directory as the program) Write another JAVA prorgram to read responses.txt file and calculate the frequency of each rating in the file and output the number and frequency in two columns (number, frequency) on the Console.
Java only please Write a program that displays the following menu: Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Triangle 3. Calculate the Area of a Rectangle 4. Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the formula: area = ∏r2 Use 3.14159 for ∏. If the user enters 2 the program should ask for...
Please use simple java code and comments no arrays Write a program that displays all the numbers from 100 to 1,000. ten per line, that are divisible by 5 and 6. Numbers are separated by exactly one space.
(NEED FULL CODE PLEASE)write a java program class to calculate and display the areas of 10 rectangles using arrays. * input validation sizes must be between 0-50 inches output to be displayed on the screen and send to an output file. *the output must appear in the following format. rectangle length width area 1 2.0 3.0 6.0 2 - - - - 10 display the rectangle with largest area. rectangle1 area= display the rectangle with smallest area. rectangle2 area=
Please create a Java Program, Using Netbeans JDK, that Asks the operator for 2 numbers, and the user's First and Last Name, and calculates the sum, difference, quotient, and product of the 2 numbers. The program should display to screen: "Hello ";{First Name Last Name} "The Sum is ": {Sum} "The Difference is ": {Difference} "The Product is: ": {Product} "The Quotient is ": {Quotient} Each student should post a Java program should have: (a) Pseudocode and (b) adjacent Java...
PLEASE UPLOAD or Write a simple PSEUDO CODE AND JAVA CODE for this program WITH COMMENTS IN BOTH TELLING WHAT EACH PART DOES. (I NEED BOTH CODES NOT JUST ONE OR THE OTHER) Problem Statement A golf club has a small tournament consisting of five golfers every weekend. The club president has asked you to design a program that does the following: Reads player’s names and their scores from the keyboard for each of the five golfers and simulates writing...
Please program in the Java language. a) Write driver class that instantiates 5 objects of class Circle with radius is an even number from 2 to 10 b) Write/define the class Circle