--------------------------------
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
public class SierpinskiStarterCode
{
public static void main(String args[])
{
int length = args.length; // getting the length of number of
argumnet from command line
// checking that number of agruments is 5 or not , if 5 then
proceed else print error message
if(length == 5 ) {
// getting the value and type-casting it in appropriate data
type
int width = Integer.parseInt(args[0]);
int height = Integer.parseInt(args[1]);
double min_area = Double.parseDouble (args[2]);
String colour = args[3];
String filename = args[4];
// printing the received value
System.out.println(" Value received \n----------------------------
");
System.out.println(" Width : "+width);
System.out.println(" height : "+height);
System.out.println(" Minimum Area : "+min_area);
System.out.println(" Colour code : "+colour);
System.out.println(" Output File name : "+filename);
System.out.println(" Generating Image...");
// BufferedImage image = new
BufferedImage(320,240,BufferedImage.TYPE_INT_RGB);
BufferedImage image = new
BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
// graphics.setBackground(Color.decode("#ffff00"));
graphics.setBackground(Color.decode(colour));
graphics.clearRect(0,0,image.getWidth()-1,image.getHeight()-1);
graphics.setColor(Color.decode(colour));
graphics.drawLine(0,image.getWidth()-1,image.getHeight()-1,0);
try
{
// ImageIO.write(image,"png",new
File("sierpinski-demo.png"));
ImageIO.write(image,"png",new File(filename));
System.out.println(" Image generated successfully and saved with
filename "+filename);
}
catch (Exception e)
{
System.err.println("Unable to write image
file!:"+e.getMessage());
}
}
else
{
System.err.println(" You must have provide 5 values from command
line \n---------------------------------------------------");
System.err.println(" usage : java <program name>
<width> <height> <minimum area> <colour>
<output file name>");
}
}
}
C windowslsystem32\cmd.exe : \Users\abhayk3x\Desktop>java SierpinskistarterCode You must have provide 5 values from command line usage : java <program name> <width> <height> <minimum area > <colour> <output file name > :Users\abhayk3x\Desktop>
CAwindows system32\cmd.exe :\Users\abhayk3x\Desktop>java Value received SierpinskistarterCode 34.6 #fff000 myoutput .png 320 240 : 320 : 240 : 34.6 : #fff000 Width height Minimum Area Colour code Output File name : myoutput.png Generating Image... Image generated successfully and saved with filename myoutput.png : \Users\abhayk3x\Desktop>
Assignment Λ You shall write a Java program that accepts 5 command-line arguments and generates an image of a Sierpinski triangle, as a 24- bit RGB PNG image file. Specifications The command-line arg...
could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...