Run this code in netbeans and screenshot the run results: source code: import java.awt.*; import javax.swing.*; public class RectangleMonday etends JFrame{ public RectangleMonday(){ setTitle("Area and Perimeter of a Rectangle"); setSize(400,400); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[]args){ RectangleMonday rectProg = new RectangleMonday(); } }
Q: This is a JAVA Pizza Builder GUI code. Please finish the program by completing the classes and…
A: Hey there, I am writing the required solution of the above stated question.Please do find the…
Q: Question 2: Implement the ShoppingCart and Product class with necessary properties so that the given…
A: code is here
Q: *Create a rectangle class using all methods given below.* *Use Java* Class Rectangle will have…
A: Define Rectangle class to store the dimensions of a rectangle. Define a parametrize constructor to…
Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File…
A: Please give positive ratings for my efforts. Thanks. PROGRAM Parser.java package com.examples;…
Q: A GUI implementation is given below. Complete the program as per comments. import java.awt.*; import…
A: A graphics-based operating system interface that uses icons, menus and a mouse to manage…
Q: How to code using Netbeans: 1.)Public int getHoursWorked()- optional (created in main method). 2.)…
A: The main() function along with the said functions in Java are shown in the following steps.
Q: What is #1 called, overloading or overriding?
A: i#1 called, overloading or overriding
Q: Implement any one of the following methods. That will be a good exercise for you if you choose to…
A: Given The answer is given below.
Q: In Q3, the ColoredCircle class has a getPerimeter() method that is different from the one in its…
A: Introduction: When a subclass (child class) in Java contains the same method as the parent class,…
Q: Considering the ObjectToClone class below, write a clone method for the class which will return a…
A: If we wаnt tо сreаte а deeр сорy оf оbjeсt X аnd рlасe it in а new оbjeсt Y then…
Q: PLZ help with the following In JAVA Which line of code will instantiate an InnerCatobject if…
A: Nested Class: In Java, the developer can create a class grouped with some other classes. The main…
Q: Consider the following code snippet. public interface Measurable { double getMeasure): } public…
A: For the given interface concept program the correct statement is ?
Q: Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from…
A: I implemented the above in below java code. Please go through it.
Q: The Character class is provided in the Javalibrary. Provide your own implementation for this class.…
A: Program Plan: Include necessary header files create a class MyCharacter declare the variable ch as…
Q: Define a Rectangle class that also inherits from Quadrilateral, with the following methods:…
A: Step-1: Start Step-2: Create a class Quadrilateral Step-2.1: Create constructor for variable length…
Q: In Java Add the following to the package below: 1.for or for...each or while loops. 2.Arrays…
A: Dear Student, In your question a while loop is already present so I am just adding a for loop and an…
Q: APEX - Salesforce Write an Apex Class to Multiply two numbes and show in the Console and please add…
A: Given: Write an Apex Class to Multiply two numbes and show in the Console and please add proper…
Q: Design a program using Java - Apache NetBeans. With the following enum class: public enum Day {…
A: Given: public enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY,THURSDAY, FRIDAY, SATURDAY}
Q: Write the Game class with the required properties to give the following outputs as shown. # Write…
A: Algorithm: Start Create a class with name Game and class members dueList, sentinelList as empty…
Q: In this java program, run this program in netbeans show the picture of the output. Source Code:…
A: The following program is executed in Apache Netbeans and the screenshot of the output is given in…
Q: Write a Java class called "Colors.java" that generates two random colors, then it applies a…
A: Below is the code in java and sample output:
Q: public class Dog { private String name; private double weight; private static int…
A: public class Dog { private String name; private double weight; private…
Q: This is for pygame Text Class The Text class inherits from Drawable and it will be used to display…
A: Instructions for the Text class:Import the Drawable class and pygame module.Create a class Text and…
Q: Implement the ShoppingCart and Product class with necessary properties so that the given output is…
A: Program: Start Create a class ShoppingCart with attributes cart, cartName Implement setCartName()…
Q: import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.ArrayList;…
A: Q
Q: Implement the line below in Java. bel' (i) = bel(i – 2) x 0.25 + bel(i – 1) x 0.5 + bel(i) × 0.25;…
A: I am using the Scanner methods nextInt() and nextLine() for reading input. It looks like this:…
Q: also need help Write a second constructor that takes a String array of pages as input and sets the…
A: 1- Rules of the array: Array must be initialized at the time of declaration otherwise it will throw…
Q: Answer the prompt with given main method: Code: import java.awt.*; public class TestRandomWalker…
A: Actually, program is a executable software that runs on a computer.
Q: Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from…
A: Here I have created the class named Polygon. Next, I have created the variable and then I have…
Q: Implement the following in java, write all classes need in the following application, in addition to…
A: Step 1: Start Step 2: Defining a function named validate to check the given criteria of a string…
Q: For this assignment, create a child class of car that creates a car of a randomly generated color.…
A: //Adding the package package javafx.swing; //Importing the required header files import…
Q: A Implement the following classes in Java. Animal class that has a private field called age, two…
A: We need to implement Animal, Bird, Spider, and Main classes as per the given description.
Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File…
A: Program Instructions: Declare a list of integers.Use string of arrays to save integers as strings by…
Q: Please help me with my assignment for computer science as I had all the dialog box pop up for me…
A: Given that Please help me with my assignment for computer science as I had all the dialog box pop up…
Q: Multiple choice in java Given the following code snippet: HashMap carsHashMap=new HashMap();…
A: Given: HashMap<Integer, Car> carsHashMap=new HashMap<>(); Car car1=new…
Q: **Java Code** Think Java Exercise 14.2 Write a loop that plays the game 100 times and keeps track of…
A: Given: Think Java Exercise 14.2 Write a loop that plays the game 100 times and keeps track of how…
Q: import java.at."; import javax. swing."; public class RectangleMonday etends JFrame{ public…
A: Introduction of Program: The java program uses the concept of JFrame and it provides a window on the…
Q: When you add a contact to your phone, it automatically sorts those names alphabetically. In this…
A: Given data addNumber- This method takes a PhoneNumber and adds it to the directory. Once the…
Q: Use Netbeans to run the following decorator pattern code. Provide screenshot to prove that the code…
A: Firstly, open the Netbeans IDE. Steps to create a project with the name spaceship: Go to new->…
Q: Create a subclass of Circle class ColoredCircle by implementing the ColoredShape interface. It…
A: Circle.java public class Circle { private double radius; private double area; private…
Q: In Java fix this problem so that it can run. The flawed pieces are highlighted -Also, use char…
A: Required: In Java fix this problem so that it can run. The flawed pieces are highlighted -Also,…
Q: Q2: Write the Java code corresponding to the following UML diagram. Then, create two objects from…
A: abstract class Polygon{ protected String color; protected int numberOfSides; public…
Q: The first one is answered as follows. Help with the second one. package test; import…
A: Hey there, I am writing the required solution for the above stated question.
Q: Create a method that will ask the user to enter a day of a week and the program should tell the mood…
A: Below is the required code in java:
Q: You should design a Skyscraper class, with private variables representing the state (i.e., the board…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: the Card.java class file, write a program to simulate a Deck of Cards. See Programming Project 8.7…
A: It is defined as a class-based object-oriented programming language for building web and desktop…
Q: animated house. import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import…
A: void drawEmptyBoard(Graphics g) { int x=x_offset, y=y_offset; Color old_col=g.getColor();…
Q: write in javascript please A cryptid is a legendary creature that, if it exists, is an animal…
A: Program Explanation: 1) Implement the header file. 2) Declare the main type integer. 3) Use any two…
Q: Write a Java program “PointTester”, that constructs two points with coordinates (3, 4) and (–3, –4).
A: First of all, we need to create two java classes in a folder named: Point.java PointTester.java…
Q: Write the different methods using public and private keywords
A: the different methods using public and private keywords
Run this code in netbeans and screenshot the run results:
source code:
Step by step
Solved in 3 steps with 1 images
- Look at the following applet code snippet: 1 import javax.swing.*; 2 import java.awt.*; 3 public class GraphicsTest extends JApplet 4 { 5 public void init() 6 { 7 getContentPane().setBackground(Color.WHITE); 8 } 9 public void paint(Graphics g) 10 { 11 int[] xCoords = {20, 20, 60, 100, 140, 140, 100, 60}; 12 int[] ycoords = {20, 100, 140, 140, 100, 60, 20, 20}; 13 super.paint(g); 14 g.setColor(Color.YELLOW); 15 g.fillPolygon(xCoords, yCoords, 8); 16 g.setColor(color.BLACK); 17 g.setFont(new Font("SansSerif", Font.BOLD, 35)); 18 g.drawString("SLOW", 35, 95); 19 } 20 } How many vertices does the polygon have? Justify your answer.Please fix errors for the java code below. The program is a t square fractal (image below) import javax.swing.*;import java.awt.*;import java.awt.geom.*; //main classpublic class SquareFractal { public static void main(String[] args) { FractalFrame tframe = new FractalFrame(); tframe.setTitle("T Square Fractal"); tframe.setVisible(true); }} //JFrame extended in fractal class class T_Fractal extends JFrame{ private JPanel panel; private int twidth, theight; private int x = 200; private int limit = 15; public T_Fractal() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //default height and width final int Width = 1000; final int Height = 1000; setSize(Width, Height); setLocation(200,50); panel = new JPanel(); Container t_content = getContentPane(); t_content.add(panel, "Center"); } public void paint(Graphics graphics) { super.paint(graphics); Graphics2D g2 = (Graphics2D) graphics; twidth = getWidth(); theight = getHeight();…Please help me fix this java code which is supposed to be a Pac-Man game Java program is below import java.awt.*; import javax.swing.JFrame.*; public class ManyPacMans extends JFrame { public void paint(Graphics g) { g.drawghostShape(60,30,40); setBackground(Color.BLUE); g.fillghostShape(130, 30,100, 80); g.drawghostShape(60,30,40); setBackground(Color.PINK); g.fillghostShape(130, 30,100, 80); g.drawghostShape(60,30,40); setBackground(Color.RED); g.fillghostShape(130, 30,100, 80); g.drawOvalpacman(30,130,50, 60); setForeground(Color.yellow); g.fillOval(130,130,50, 60); } public Ghost(String imgPath, int x, int y, int speed, boolean ip) { super(imgPath, new int[] {0,0}, GHOST_WIDTH, GHOST_HEIGHT, GHOST_FRAMERATE, x, y); super.addFramesForAnimation("scatter", "ghost_scatter.png", 0, 0, 22,0); super.speed = speed; startX = x; startY = y; scoreValue = 200; } public ManyPacMans() { initUI(); } private void initUI() { add(new…
- please build up the java codecomplete the code and fill up missing codes// = needs input for the code thank you import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.ArrayList; public class GUI extends JFrame implements ActionListener {JMenuItem resetItem, startItem;JTextField ansTextField;JLabel resultLabel, scoreLabel, timeLabel, operationLabel;Timer timer;DoubleDigitOp op;final int maxTime = 6;final int runTime = 100;double score = 0;int newTime = maxTime*runTime;String[] status = new String[]{"Score: ","Timer: "};String[] reset = new String[]{"Score: 0.00","Timer: "+((double)newTime/100),"00 + 00 = ","Game Message"};public GUI(String title){setTitle(title);//Create a Menu names "Game" (1) //Add two menus on "Game": the menus named "Start" and "Reset" (6) -- both execute an actionJMenuBar menuBar = new JMenuBar();menuBar.add(gameMenu);setJMenuBar(menuBar);JPanel content = new JPanel();content.setLayout(new BorderLayout());JPanel statusPanel = new…PRACTICE CODE import java.util.TimerTask;import org.firmata4j.ssd1306.MonochromeCanvas;import org.firmata4j.ssd1306.SSD1306;public class CountTask extends TimerTask {private int countValue = 10;private final SSD1306 theOledObject;public CountTask(SSD1306 aDisplayObject) {theOledObject = aDisplayObject;}@Overridepublic void run() {for (int j = 0; j <= 3; j++) {theOledObject.getCanvas().clear();theOledObject.getCanvas().setTextsize(1);theOledObject.getCanvas().drawString(0, 0, "Hello");theOledObject.display();try {Thread.sleep(2000);} catch (InterruptedException e) {throw new RuntimeException(e);}theOledObject.clear();theOledObject.getCanvas().setTextsize(1);theOledObject.getCanvas().drawString(0, 0, "My name is ");theOledObject.display();try {Thread.sleep(2000);} catch (InterruptedException e) {throw new RuntimeException(e);}while (true) {for (int i = 10; i >= 0; i--)…Write this code to get 7 inputs: import javax.swing.*;import java.awt.*;import java.awt.event.*; class WeeMadLib implements ActionListener { JFrame wmlGame = new JFrame("Wee Mad Lib");JPanel gameBoard = new JPanel(new GridLayout(3,3)); JLabel subjectLabel = new JLabel("Subject");JLabel verbLabel = new JLabel("Verb");JLabel objectLabel = new JLabel("Object"); JLabel subject = new JLabel("My friend ");JTextField verb = new JTextField(25);String[] objectOptions = { " a ball."," chickens."," a kazoo.", " an igloo." };JComboBox object = new JComboBox(objectOptions); JButton clear = new JButton("Clear");JTextArea sentence = new JTextArea("My friend ___ ___.");JButton exit = new JButton("Exit"); public WeeMadLib() { wmlGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); wmlGame.setSize(300,300); subjectLabel.setOpaque(true); subjectLabel.setBackground(new Color(0,255,255)); subjectLabel.setHorizontalAlignment(JLabel.CENTER); sentence.setEditable(false); sentence.setOpaque(false);…
- Java ProgramEdit this program that when you press the clear button, it actually clears the textfield and data of the previous numbers pressed.import java.awt.BorderLayout;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import javax.swing.*;public class Pincode extends JPanel implements ActionListener {JLabel display, displayExtra;JButton numButton;JButton clr;JButton etr;String displayContent = "";String[] numPadContent = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "CLEAR", "0", "ENTER"};ArrayList<JButton> buttonList;String PASSWORD = "061904";JFrame f;Pincode(Container pane) {pane.setPreferredSize(new Dimension(320, 335));display = new JLabel(displayContent);displayExtra = new JLabel(displayContent);display.setPreferredSize(new Dimension(320, 25));display.setBorder(BorderFactory.createLoweredBevelBorder());pane.add(display,…import java.util.Arrays; import java.util.Scanner; public class Game { private Player[] players; private Board board; private int currentPlayerIndex; private int numOfPlayers; private Scanner scanner = new Scanner(System.in); // constructor public Game(){ //create a new board; this.board = new Board(); //setup game; this.setupGame(); //start game; this.play(); } //Game Setup public void setupGame(){ System.out.println("How many players would you like to included in this game? (2-4)"); numOfPlayers = scanner.nextInt(); while (numOfPlayers < 2 || numOfPlayers > 4) { System.out.println("Invalid input. Please enter a number between 2 and 4."); numOfPlayers = scanner.nextInt(); } scanner.nextLine(); String[] playerNames = new String[numOfPlayers]; this.players = new…DEUGGING PROBLEM // Prompts user for a size using Scanner // Creates a frame with the specified size // that is twice as tall as wide import javax.swing.*; import java.util.*; public class DebugFourteen1 extends JFrame { public DebugFourteen1(int size) { super("This is my frame"); setSize(size, size + 2); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { Scanner kb = new Scanner(System.in); int size; System.out.print("Enter width for frame >> "); size = kb.nextLine(); DebugFourteen1 frame = new DebugFourteen1(size); frame.setVisible(); } }
- import java.awt.*;import javax.swing.*;import java.util.*; // Model classclass FrogModel { private int xc; private int yc; public FrogModel() { // Initialize frog's coordinates randomly Random rng = new Random(); // Creating an instance of Random xc = rng.nextInt(200); yc = rng.nextInt(200); } public int getX() { return xc; } public int getY() { return yc; } public void leap() { // Update frog's coordinates randomly Random rng = new Random(); // Creating an instance of Random xc = rng.nextInt(200); yc = rng.nextInt(200); }} // View classclass FrogView extends JPanel { private FrogModel model; public FrogView(FrogModel model) { this.model = model; setBackground(Color.BLUE); } @Override protected void paintComponent(Graphics gc) { super.paintComponent(gc); gc.setColor(Color.GREEN); gc.fillOval(model.getX(), model.getY(), 10, 10); //…import java.util.Scanner; public class TriangleArea { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Triangle triangle1 = new Triangle(); Triangle triangle2 = new Triangle(); // TODO: Read and set base and height for triangle1 (use setBase() and setHeight()) // TODO: Read and set base and height for triangle2 (use setBase() and setHeight()) System.out.println("Triangle with smaller area:"); // TODO: Determine smaller triangle (use getArea()) // and output smaller triangle's info (use printInfo()) }} public class Triangle { private double base; private double height; public void setBase(double userBase){ base = userBase; } public void setHeight(double userHeight) { height = userHeight; } public double getArea() { double area = 0.5 * base * height; return area; } public void printInfo() { System.out.printf("Base:…import java.awt.*;import javax.swing.*;import java.util.*; // Model classclass FrogModel { private int xc; private int yc; public FrogModel() { // Initialize frog's coordinates randomly Random rng = new Random(); // Creating an instance of Random xc = rng.nextInt(200); yc = rng.nextInt(200); } public int getX() { return xc; } public int getY() { return yc; } public void leap() { // Update frog's coordinates randomly Random rng = new Random(); // Creating an instance of Random xc = rng.nextInt(200); yc = rng.nextInt(200); }} // View classclass FrogView extends JPanel { private FrogModel model; public FrogView(FrogModel model) { this.model = model; setBackground(Color.BLUE); } @Override protected void paintComponent(Graphics gc) { super.paintComponent(gc); gc.setColor(Color.GREEN); gc.fillOval(model.getX(), model.getY(), 10, 10); //…