Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java: Coin Automata Problem Set: A grid has been established below where we place a marker on the circle numbered 1. We will toss a

Java: Coin Automata

Problem Set: A grid has been established below where we place a marker on the circle numbered 1. We will toss a coin. If the coin toss resulted in a 'heads', we would move the marker along the path labeled 'H' to the circle numbered 5. If the coin toss resulted in a 'tails', we would move the marker along the path labeled 'T' to the circle numbered 4. Based on the grid established the coin tosses are repeated again to move the marker accordingly. The purpose of this problem is to simulate this automata and to report the number of the circle on which the marker ends after a series of coin tosses.

The marker always begins on the circle numbered 1.

image text in transcribed

Input: Java should accept a string consisting only of the characters 'h' (heads) or 't' (tails), where each character represents the outcome of a coin toss. The string is terminated by a '#' character. Each character of the string triggers a move of the marker according to the grid above. Java should continue to prompt strings until a 'q' is entered for the string where the program should terminate without any further output.

Example Output:

Enter tosses: hhhtthththtttthht#

The marker ends on circle 3

Enter tosses: hththththt#

The marker ends on circle 6

Enter tosses: q

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

Step: 3

blur-text-image

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

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago

Question

Define Management or What is Management?

Answered: 1 week ago

Question

Understand why empowerment is so important in many frontline jobs.

Answered: 1 week ago