Question

How can I change the following program and Implement a print() method for Percolation that prints...

How can I change the following program and Implement a print() method for Percolation that prints 1 for blocked site, 0 for open sites and * for full sites?

public class Visualizeheimadaemi {
public static void main(String[] args) {
int N = Integer.parseInt(args[0]);
double p = Double.parseDouble(args[1]);
int M = Integer.parseInt(args[2]);

// repeatedly created N-by-N matrices and display them using standard draw
for (int i = 0; i < M; i++) {
boolean[][] open = Percolation.random(N, p);
StdDraw.clear();
StdDraw.setPenColor(StdDraw.BLACK);
Percolation.show(open, false);
StdDraw.setPenColor(StdDraw.GRAY);
boolean[][] full = Percolation.flow(open);
Percolation.show(full, true);
StdDraw.show(1000);
}
}
}


// 1 for blocked
// 0 for open
// * for full sites

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
How can I change the following program and Implement a print() method for Percolation that prints...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Java code for percolation, code compiles correctly but when it takes values for Input10.txt , the...

    Java code for percolation, code compiles correctly but when it takes values for Input10.txt , the code is suppose to comeback that the system percolates but instead it comes back with the exception. Photos below show the exception. I belive there may be an issue with my logic in the for loop for when to throw the exception. also, i have put the values of Input10.txt at the bottom to try and use to see the exception. The exception i...

  • Simulate how many steps its take a random walker starting at the center of an 10x10...

    Simulate how many steps its take a random walker starting at the center of an 10x10 grid to visit every cell of the grid. If the walker tries to go outside of the grid then it doesn't move in that step. Write a java program which simulates th steps of the random walker, and keeps hold about the grid with 2D boolean array and write out the steps when the random walker have walked all the cells. ----------------------------------------------------------------------------------------------- I have...

  • I must implement a class to calculate n-th row of Pascal's Triangle (in Java). I need...

    I must implement a class to calculate n-th row of Pascal's Triangle (in Java). I need to create a static method that takes an argument "n" and returns the n'th line of pascal's triangle. the main method, which will call the class, is already done and the class is set up. Please build this without modifying the main method and without modifying exactly what the static method returns. public class Main { public static void main(String[] args) { int n...

  • Create a method based program to find if a number is prime and then print all...

    Create a method based program to find if a number is prime and then print all the prime numbers from 1 through 500 Method Name: isPrime(int num) and returns a boolean Use for loop to capture all the prime numbers (1 through 500) Create a file to add the list of prime numbers Working Files: public class IsPrimeMethod {    public static void main(String[] args)    {       String input;        // To hold keyboard input       String message;      // Message...

  • Create a program named NonZeroNumQueue.java then copy the contents from NonZeroNumQueue.txt. Then implement enqueue method. To...

    Create a program named NonZeroNumQueue.java then copy the contents from NonZeroNumQueue.txt. Then implement enqueue method. To get credit, DO NOT add or alter any data members/methods except the enqueue(int num). The NonZeroNumQueue will NOT accept zero, which mean you can enqueue any whole numbers EXCEPT 0(zero). You have already noticed that the queue is NEVER full, so the isFull() always returns false. given NonZeroNumQueue.txt public class NonZeroNumQueue{ private int[] data; private int total; private int front; private int tail; public...

  • JAVA: How do I output all the data included for each employee? I can only get...

    JAVA: How do I output all the data included for each employee? I can only get it to output the name, monthly salary and annual salary, but only from the Employee.java file, not Salesman.java or Executive.java. Employee.java package project1; public class Employee { private String name; private int monthlySalary; public Employee(String name, int monthlySalary) { this.name = name; this.monthlySalary = monthlySalary; } public int getAnnualSalary() { int totalPay = 0; totalPay = 12 * monthlySalary; return totalPay; } public String...

  • I need a java program that prints the following: 1* 2** 3*** 4**** 5***** 6****** 7*******...

    I need a java program that prints the following: 1* 2** 3*** 4**** 5***** 6****** 7******* 8******** 9********* This is what I have so far, but I cannot figure out how to fix it. public class HelloWorld{ public static void main(String []args){ System.out.println("Pattern Two");    for (int line=1; line<10; line++){ System.out.println(); for (int j=1; j System.out.print(line); for (int i=1; i System.out.print("*"); } } } } }

  • Translate the following C code into RISC-V Assembly. (no need to implement the prints just use...

    Translate the following C code into RISC-V Assembly. (no need to implement the prints just use ecall) int a[] = {2,2,5,3,4,8,3}; int b[] = {1,4,2,0,-1,5,4}; int z[7]; void multiply(int* a, int* b, int* c, int d) { for (int i=0; i < d; i++) { c[i] = a[i] * b[i]; } } int main() { int n = 7; multiply(a,b,z,n); printf("%s", "res: "); for (int i = 0; i < z; i++) { printf("%d", d[i]); } printf("\n"); return 0; }

  • My Question is: I have to modify this program, even a small modification is fine. Can...

    My Question is: I have to modify this program, even a small modification is fine. Can anyone give any suggestion and solution? Thanks in Advanced. import java.util.*; class arrayQueue { protected int Queue[]; protected int front, rear, size, len; public arrayQueue(int n) { size = n; len = 0; Queue = new int[size]; front = -1; rear = -1; } public boolean isEmpty() { return front == -1; } public boolean isFull() { return front == 0 && rear ==size...

  • re-implement the Bookshelf class using a linkedlist and a Node class. Implement the above add, remove,...

    re-implement the Bookshelf class using a linkedlist and a Node class. Implement the above add, remove, and search methods again. here is the code for that: public class Book {    private String title; private double price;    public Book() { title=""; price=0; }    public Book(String title, double price) { this.title = title; this.price = price; }    public void setTitle(String title) { this.title = title; }    public void setPrice(double price) { this.price = price; }    public...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT