Based on the information in the screenshots, please answer the following question below. The language used is Java and please provide the code for it with the explanation. Create a testing class named “PlanTest”. Under this class, there needs to be another static method besides the main method: You will need to create a static method named “prerequisiteGenerator” under “PlanTest”, which return a random 2D array containing prerequisite pairs (e.g., {{1, 3}, {2, 3}, {4, 2}}). The value range of a random integer is [0, 10] (inclusive). This method will accept an integer parameter, which specifies the length of the returned array: int[][] pre = prerequisiteGenerator(3); // possibly {{1, 3}, {2, 3}, {4, 2}} Under the main method, you will need to use prerequisiteGenerator to generate random prerequisite pair lists, and perform tests on plan method at least three examples by printing proper messages. Given 4 courses and prerequisites as [[1,0], [2,0], [3,1]] It is possible to take all the given courses. A possible schedule is 0, 1, 2, 3.
Based on the information in the screenshots, please answer the following question below. The language used is Java and please provide the code for it with the explanation. Create a testing class named “PlanTest”. Under this class, there needs to be another static method besides the main method: You will need to create a static method named “prerequisiteGenerator” under “PlanTest”, which return a random 2D array containing prerequisite pairs (e.g., {{1, 3}, {2, 3}, {4, 2}}). The value range of a random integer is [0, 10] (inclusive). This method will accept an integer parameter, which specifies the length of the returned array: int[][] pre = prerequisiteGenerator(3); // possibly {{1, 3}, {2, 3}, {4, 2}} Under the main method, you will need to use prerequisiteGenerator to generate random prerequisite pair lists, and perform tests on plan method at least three examples by printing proper messages. Given 4 courses and prerequisites as [[1,0], [2,0], [3,1]] It is possible to take all the given courses. A possible schedule is 0, 1, 2, 3.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Based on the information in the screenshots, please answer the following question below. The language used is Java and please provide the code for it with the explanation.
Create a testing class named “PlanTest”. Under this class, there needs to be another static method besides the main method:
- You will need to create a static method named “prerequisiteGenerator” under “PlanTest”, which return a random 2D array containing prerequisite pairs (e.g., {{1, 3}, {2, 3}, {4, 2}}). The value range of a random integer is [0, 10] (inclusive). This method will accept an integer parameter, which specifies the length of the returned array:
int[][] pre = prerequisiteGenerator(3); // possibly {{1, 3}, {2, 3}, {4, 2}}
- Under the main method, you will need to use prerequisiteGenerator to generate random prerequisite pair lists, and perform tests on plan method at least three examples by printing proper messages.
Given 4 courses and prerequisites as [[1,0], [2,0], [3,1]]
It is possible to take all the given courses.
A possible schedule is 0, 1, 2, 3.
![Ехample 2:
2, [[1,01,[0,1]]
Output:
It is impossible to take all the given courses.
Explanation:
There are a total of 2 courses to take. To take course 1 you should have finished course
0, and to take course 0 you should also have finished course 1.
This class needs to be named “CoursePlanner". The methods that solve the problem
w
are arranged as
plan: this method returns no value and prints out (b) whether it is possible to
take all the given courses and (b) what a possible schedule looks like.
check: this method returns a boolean value to indicate whether it is possible to
take all the given courses. This method can be seen as a helper for plan](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4cd974de-0ca5-43c4-9c5f-a02c9b7b2d9a%2F70541c22-b84c-462c-a7fa-44da75276ec2%2F1nf7bc_processed.png&w=3840&q=75)
Transcribed Image Text:Ехample 2:
2, [[1,01,[0,1]]
Output:
It is impossible to take all the given courses.
Explanation:
There are a total of 2 courses to take. To take course 1 you should have finished course
0, and to take course 0 you should also have finished course 1.
This class needs to be named “CoursePlanner". The methods that solve the problem
w
are arranged as
plan: this method returns no value and prints out (b) whether it is possible to
take all the given courses and (b) what a possible schedule looks like.
check: this method returns a boolean value to indicate whether it is possible to
take all the given courses. This method can be seen as a helper for plan
![Suppose you are working on creating an automatic course planner for WWU students.
A student can get a total ofn courses, labeled from 0 ton - 1.
Some courses may have prerequisites, for example, to take course 241 you have to first
--.
take course 145, which is expressed as a pair: [241, 145] (the current course, the
prerequisite of the current course).
Given the total number of courses and a list of prerequisite pairs, you need to:
Determine if it is possible to finish taking the n courses. If not, print “It is
impossible to take all the given courses." If yes, print "It is possible to take all
the given courses.", and move to the next step.
Generate one schedule of the given courses (prerequisites have to be scheduled
first for any courses). Print the courses out with white spaces as separators.
There might be multiple valid schedules, but you only need to generate one of
them.
Еxample 1:
4, [[1,0], [2,0], [3,1]]
Output:
It is possible to take all the given courses.
A possible schedule is 0, 1, 2, 3.
Explanation:
There are a total of 4 courses to take. To take courses 1 or 2 you should take course 0
first. To take course 3, you should take 1 first.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F4cd974de-0ca5-43c4-9c5f-a02c9b7b2d9a%2F70541c22-b84c-462c-a7fa-44da75276ec2%2F2chp89_processed.png&w=3840&q=75)
Transcribed Image Text:Suppose you are working on creating an automatic course planner for WWU students.
A student can get a total ofn courses, labeled from 0 ton - 1.
Some courses may have prerequisites, for example, to take course 241 you have to first
--.
take course 145, which is expressed as a pair: [241, 145] (the current course, the
prerequisite of the current course).
Given the total number of courses and a list of prerequisite pairs, you need to:
Determine if it is possible to finish taking the n courses. If not, print “It is
impossible to take all the given courses." If yes, print "It is possible to take all
the given courses.", and move to the next step.
Generate one schedule of the given courses (prerequisites have to be scheduled
first for any courses). Print the courses out with white spaces as separators.
There might be multiple valid schedules, but you only need to generate one of
them.
Еxample 1:
4, [[1,0], [2,0], [3,1]]
Output:
It is possible to take all the given courses.
A possible schedule is 0, 1, 2, 3.
Explanation:
There are a total of 4 courses to take. To take courses 1 or 2 you should take course 0
first. To take course 3, you should take 1 first.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY