Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Written in Java There are 1 to N non-intersecting circles (where N be any number between 2 and 10). Start at circle 1 and randomly

Written in Java image text in transcribed
There are 1 to N non-intersecting circles (where N be any number between 2 and 10). Start at circle 1 and randomly choose among the out arrows (all out arrows should be equally likely to be picked). The next circle is the new current circle. Each visited circle gets a "check mark" to indicate it has been visited. Once all circles have at least one check mark, stop the game. Write a program that will read from a textfile and write to another textfile. The input file will have N and K positive integers, where: N is the FIRST LINE and K is the SECOND LINE indicating number or arrows between the circles. The next K lines indicate the arrows. Each arrow line consists of two numbers, each number being one of circles in the game. These two numbers are separated by a single blank. The first number designates the circle that is the source (back end) of the arrow; the second number designates the circle that is the destination (pointed end) of the arrow. Note: If the text in the input file does not follow the format described above, your program should end with an error message to the screen and to an output file. At the end of the game, print out to the screen AND to the output textfile, the following numbers: 1. The number of circles that were used for this game 2. The number of arrows that were used for this game 3. The total number of checks on all the circles combined 4. The average number of checks in a circle marked during the game. 5. The maximum number of checks in any one circle

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions