Related questions
Please help me with this java code. The
import java.awt.image.*;
import java.awt.Color;
import java.io.*;
import javax.imageio.*;
public class Main
{
static final int DIMENSION = 1000;
static BufferedImage image = new BufferedImage(DIMENSION, DIMENSION, BufferedImage.TYPE_INT_RGB);
static final int WHITE = Color.WHITE.getRGB();
static final int BLACK = Color.BLACK.getRGB();
private static void drawSquare(int x, int y, int side)
{
if (side <= 0)
return;
else
{
int left = x - side/2;
int top = y - side/2;
int right = x + side/2;
int bottom = y + side/2;
for (int i = left; i < right; i++)
for (int j = top; j < bottom; j++)
{
image.setRGB(i, j, BLACK);
}
drawSquare(left, top, side/2);
drawSquare(left, bottom, side/2);
drawSquare(right, top, side/2);
drawSquare(right, bottom, side/2);
}
}
public static void main (String[] args) throws IOException
{
for (int i = 0; i < DIMENSION; i++)
for (int j = 0; j < DIMENSION; j++)
{
image.setRGB(i, j, WHITE);
}
drawSquare(DIMENSION/2, DIMENSION/2, DIMENSION/2);
File imagefile = new File("tfractal.jpg");
ImageIO.write(image, "jpg", imagefile);
}
}
Step by stepSolved in 2 steps with 1 images
- Identify errors from the following program and correct them. import java.swing.*; import java.awt.*; public class Cake extends Panel { public final double CREAM_CHEESE = 0.50 public final double BUTTER = 0.25; public final double PEACH_JELLY = 0.75; public final double BLUEBERRY_JAM = 0.75; private JCheckBox creamCheese; private JCheckBox butter; private JCheckBox peachJelly; private JCheckBox blueberryJam; public Cake() { setLayout new GridLayout(4, 1)); creamCheese = new JCheckBox("Cream cheese"); butter = new JCheckBox("Butter"); peachJelly = new JCheckBox("Peach jelly"); blueberryJam = new JCheckBox("Blueberry jam"); setBorder(BorderFactory.createTitledBorder("Cake Decorations")); add(creamCheese); add(butter); add(peachJelly); add(blueberryJam); } public double getDecorationCosts() { double decorationCosts = 0; if (creamCheese.isSelected()) decorationCosts += CREAM_CHEESE; if (butter.isSelected()) decorationCosts += BUTTER; if (peachJelly.isSelected())...arrow_forwardPlease help, I don't know why this java matching game code is not working. image provided below shows what image program show import javax.swing.*;import java.awt.event.*;import java.awt.*; public class Halloween { // 2D array to store the Halloween-themed images final int[][] hallow = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}; final int rows = 4; int cols = 3; JButton pics[] = new JButton[rows * cols]; public static void main(String[] args) { // Create a JFrame with a grid layout JFrame frame = new JFrame("Halloween"); frame.setLayout(new GridLayout(rows, cols)); // Add buttons to the JFrame int m = 0; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { pics[m] = new JButton(createImageIcon("back.png")); pics[m].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // Get the index...arrow_forwardDouble any element's value that is less than controlValue. Ex: If controlValue = 10, then dataPoints = {2, 12, 9, 20} becomes {4, 12, 18, 20}. import java.util.Scanner; public class StudentScores { public static void main (String [] args) { Scanner scnr = new Scanner (System.in); final int NUM_POINTS = 4; int [] dataPoints new int [NUM_POINTS]; int controlValue; int i; controlValue = scnr. nextInt (); for (i = 0; i < dataPoints.length; ++i) { = scnr.nextInt (); dataPoints [i] } /* Your solution goes here * / for (i = 0; i < dataPoints.length; ++i) { System.out.print (dataPoints[i] + %3D " ") ; } System.out.println ();arrow_forward
- java programming I have a Java program with a restaurant/store menu. Can you please edit my program when displaying the physical receipt? I would like the physical receipt to export a PDF file, not printing the order receipt in the console. import java.util.*; public class Restaurant2 { publicstaticvoidmain(String[] args) { // Define menu items and pricesString[] menuItems= {"Apple", "Orange", "Pear", "Banana", "Kiwi", "Strawberry", "Grape", "Watermelon", "Cantaloupe", "Mango"};double[] menuPrices= {1.99, 2.99, 3.99, 4.99, 5.99, 6.99, 7.99, 8.99, 9.99, 10.99};StringusersName; // The user's name, as entered by the user.ArrayList<String> arr = new ArrayList<>(); // Define scanner objectScanner input=new Scanner(System.in); // Welcome messageSystem.out.println("Welcome to AppleStoreRecreation, what is your name:");usersName = input.nextLine(); System.out.println("Hello, "+ usersName +", my name is Patrick nice to meet you!, May I Take Your Order?"); // Display menu items...arrow_forwardHow do I fix the Java code errors? Code: //import java.util.Arrays;//Movie.java package movie; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; public Movie() { movieName = "Flick"; numMinutes = 0; isKidFriendly = false; numCastMembers = 0; castMembers = new String[10]; } public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; this.numCastMembers = castMembers.length; this.castMembers = castMembers; } public String getMovieName() { return this.movieName; } public int getNumMinutes() { return this.numMinutes; } public boolean getIsKidFriendly() { return this.isKidFriendly; } public boolean isKidFriendly() {...arrow_forwardQUICKLY please. Thank you. Please answer in python quickly Below is code that defines a Quadrilateral class (a shape with four sides), which has four floating point instance variables that correspond to the four side lengths: import math class Quadrilateral: def __init__(self,a,b,c,d): self.a = a self.b = b self.c = c self.d = d def perimeter(self): return self.a + self.b + self.c + self.d def area(self): print("Not enough information") def __lt__(self, other): return self.perimeter() < other.perimeter() Define a Rectangle class that inherits from Quadrilateral, with the following methods: __init__(self, length, width): Override the __init__ method so that the Rectangle constructor only takes in two floating point numbers. Your constructor for Rectangle should only consist of a call to Quadrilateral’s constructor: don’t define any new instance variables. Override the area method to...arrow_forward
- Please help me with this using java. create a trivia game menu. Include the following: 1. Background (using fractals and recursion) (I would like a black brick wall as as the fractal for the background of the game menu 2. include the three clickable buttons ( play, settings, and instructions) 3. Include a title (Quiz time) (Image show below)arrow_forwardPlease help me with this using java. create a java code for a trivia game. Include a game menu with the option of play game, settings, and instructions. The game menu must also have a graphics as well. please use the following when creating the game menu and the game 1. Arrays 2. recursion 3. fractals 4. GUI 5. Inheritance 6. Insertion 7. Class and objectsarrow_forwardHow do I make the Java code output? //import java.util.Arrays;public class Movie {private String movieName;private int numMinutes;private boolean isKidFriendly;private int numCastMembers;private String[] castMembers;// default constructorpublic Movie() {this.movieName = "Flick";this.numMinutes = 0;this.isKidFriendly = false;this.numCastMembers = 0;this.castMembers = new String[10]; }// overloaded parameterized constructorpublic Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) {this.movieName = movieName;this.numMinutes = numMinutes;this.isKidFriendly = isKidFriendly;//numCastMember is set to array lengththis.numCastMembers = castMembers.length;this.castMembers = castMembers; }public String getMovieName() {return this.movieName; }public int getNumMinutes() {return this.numMinutes; }public boolean getIsKidFriendly() {return this.isKidFriendly; }public boolean isKidFriendly() {return this.isKidFriendly; }public int getNumCastMembers() {return...arrow_forward
- using java (Use the Date class) Write a program that creates a Date object, sets its elapsedtime to 10000, 100000, 1000000, 10000000, 100000000, 1000000000,10000000000, and 100000000000, and displays the date and time using thetoString() method, respectively.arrow_forwardJAVA PROGRAMMING LANGUAGE PLEASE. Convert the following UML to code in the image given below.arrow_forward// the language is java according to this code, do the next steps. /class for check even or odd number class CheckEvenOdd implements Runnable { private int maxLimit; private Printer printer; private boolean isEvenNumber; public CheckEvenOdd(Printer printer,int maxLimit,boolean isEvenNumber) { this.maxLimit = maxLimit; this.isEvenNumber = isEvenNumber; this.printer = printer; } @Override public void run() { int number = isEvenNumber ? 2 : 1; while (number <= maxLimit) { if (isEvenNumber) { printer.printEven(number); } else { printer.printOdd(number); } number += 2; } } } //Printer class for print the number with thread name class Printer { private volatile boolean isOdd; synchronized void printEven(int number) { while (!isOdd) { try { wait(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } System.out.println(Thread.currentThread().getName() + " thread :" + number); isOdd = false; notify(); } synchronized void printOdd(int number) { while (isOdd) { try {...arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education