Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Set: Let's place a marker on the circle numbered 1 in the grid below. Then we will toss a coin. If the coin toss

image text in transcribed

Problem Set: Let's place a marker on the circle numbered 1 in the grid below. Then 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 ( 1 tails', we would move the marker along the path labeled T' to the circle numbered 4. Now we would toss the coin again and move the marker accordingly. This is repeated for any number of coin tosses. 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. 2. 7 Input: Your program should accept a string consisting only of the characters 'h' or 't, where each character represents the outcome of a coin toss ('h'- heads, 't-tails). The string is terminated by a"#"character. Each character of the string triggers a move of the marker according to the rules above. A suitable prompt for the entry of this string would be 'Enter tosses: "Your program should continue to prompt strings until a 'q' is entered for the string. At this point, your program should terminate without any further output. Output For each input when the string terminator is reached, output a line of the form show below, where X is the number of the circle the marker ends up on. The marker ends on circle X Example Execution: Enter tosses: hhhtthththtttthht# The marker ends on circle 3 Enter tosses: hththththt# The marker ends on circle 6 Enter tosses

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

10:16 AM Sun Jan 29 Answered: 1 week ago

Answered: 1 week ago

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago