




import java.awt.Graphics;
import java.awt.Color;
import java.util.*;
public class HW02_Starter_Code
{
public static DrawingPanel canvas;
public static Graphics g;
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int R,G,B,s_across,s_tall;
int x=0;int y=15;
System.out.println("Enter RGB codes");
R=sc.nextInt();
G=sc.nextInt();
B=sc.nextInt();
System.out.println("How many stars across");
s_across=sc.nextInt();
System.out.println("How many stars tall");
s_tall=sc.nextInt();
canvas = new DrawingPanel(s_across*50,s_tall*50);
g = canvas.getGraphics();
g.setColor(new Color(R,G,B));
for(int i=0;i<=s_across*50;i++)
{
for(int j=0;j<=s_tall*50;j++)
{
star(x,y);
x=x+50;
}
y=y+50;
x=0;
}
}
public static void star(int x,int y)
{
g.drawLine(x,y,x+50,y);
g.drawLine(x+50,y,x+7,y+35);
g.drawLine(x+7,y+35,x+25,y-15);
g.drawLine(x+25,y-15,x+43,y+35);
g.drawLine(x+43,y+35,x,y);
}
}
// compile and run and remember it needs DrawingPanel.java to run//
//run this file while having this and DrawingPanel.java is one folder//
//Compiled ,executed and tested //
Write a program which will Ask the user a series of questions using the Scanner object Based on t...
User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...
With your partner, brainstorm a program that will ask the user for a number of digits to be stored. The program should then create an array of that size and then prompt the user for numbers to fill each position in the array. When all of the positions are filled, display the contents of the array to the user. Create a new Project named FillArray and a new class in the default packaged named FillArray.java. You and your partner should...
Modify the NervousShapes program so that it displays equilateral
triangles as well as circles and rectangles. You will need to
define a Triangle class containing a single instance variable,
representing the length of one of the triangle’s sides. Have the
program create circles, rectangles, and triangles with equal
probability. Circle and Rectangle is done, please comment on your
methods so i can understand
*/
package NervousShapes;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.event.*;
public class...
Write a JAVA program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values. Starter code: import java.util.Scanner; public class MaxMinGrades{ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter as many student grades as you like. Enter a character to stop."); double grade = input.nextDouble(); double minGrade = Double.MAX_VALUE; double maxGrade = Double.MIN_VALUE; while (Character.isDigit(grade)) { if (grade == 0)...
Write a program that will check a Java file for syntax errors. The program will ask for an input-file name and output-file name and will then copy all the code from the Java input file to the Java output file, but with the following changes: 1. Any syntax error found in the Java input file will be corrected: a. Missing semicolon b. Missing compound statements (curly braces) c. All comments have to start with // and end with a period....
I am using Ocelot to write a program in JavaScript Our question
is below:
Write a function called removeBlueAndGreen that takes an
image as an argument and returns a red version of the input image.
To do so, create a copy of the input and iterate over each pixel.
If the color of a pixel is (r, g, b) in the input image, its color
in the output must be (r, 0.0, 0.0).
Now is I write
let robot =...
So i need help with this program, This program is supposed to
ask the user to input their weight on earth so I would put "140"
then it would ask "enter planet name, Min, Max or all" and if the
user typed in all it would display all the planets and your weight
on them. Right now Im suck on the part where im required to do a
switch statement with a linear search. Below this im going to put...
Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. Also note: If the submitted code has an infinite loop, the system will stop running the code after a few seconds,...
***This is a JAVA question***
------------------------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import javax.swing.*;
import javax.swing.event.*;
public class DrawingPanel implements ActionListener {
public static final int DELAY = 50; // delay between repaints in
millis
private static final String DUMP_IMAGE_PROPERTY_NAME =
"drawingpanel.save";
private static String TARGET_IMAGE_FILE_NAME = null;
private static final boolean PRETTY = true; // true to
anti-alias
private static boolean DUMP_IMAGE = true; // true to write
DrawingPanel to file
private int width, height; // dimensions...
Question 4 (3 mark) : Write a Java program to ask the user to input an integer number from the keyboard. The output should indicate whether it is positive, zero, or negative, an even number or an odd number. REQUIREMENTS • Your code should ask user to input an integer number, then decide its sign and parity based on this input. • Your code should use if-else statement. Your code must work exactly as the specification and the output should...