Cocullo's snake festival held on the 1st May in celebration of Saint Domenico must win awards for being not just one of Italy's strangest festivals, but also for being the most multi-cultural. The attraction of snakes seems to be a huge pull factor. The chef was tasked with reporting on the parade, so he decided to watch all the snakes first. When he sees the snake first, it will be his head, so he marks the "H". Snakes are long, and when they see the snake finally scurry away, they mark its tail with a "T". In the interim, when the snake is moving around it, or in the time between one snake and the next snake, it marks a '.. Since the snakes come in a procession and one by one, a valid message would be something like "..H..T...HTH….…...T.", or "...", or "HT", while "T...H..H.T", "H..T..H", "H..H..T..T" would be invalid messages (see explanation below). Formally, a snake is represented by an 'H' followed by some (possibly null) '.' and then 'T'. A valid message is one that begins with the (probably zero-length) string '.' and then some (possibly zero) snakes, with some '.'s in between, and finally some (possibly zero) '.'s. The chef was devouring the festival food and was very sleepy. So his message may be invalid. You have to help him find out if his message is valid or not using Java Programming language.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Cocullo's snake festival held on the 1st May in celebration of Saint Domenico must win awards for
being not just one of Italy's strangest festivals, but also for being the most multi-cultural. The
attraction of snakes seems to be a huge pull factor. The chef was tasked with reporting on the
parade, so he decided to watch all the snakes first. When he sees the snake first, it will be his head,
so he marks the "H". Snakes are long, and when they see the snake finally scurry away, they mark
its tail with a "T". In the interim, when the snake is moving around it, or in the time between one
snake and the next snake, it marks a ‘.'.
Since the snakes come in a procession and one by one, a valid message would be something like
"..H..T...HTH....T.", or "...", or "HT", while "T ...H..H.T", "H..T..H", "H..H..T..T" would be invalid
messages (see explanation below).
Formally, a snake is represented by an 'H' followed by some (possibly null) '.' and then 'T'. A valid
message is one that begins with the (probably zero-length) string '!' and then some (possibly zero)
snakes, with some '.'s in between, and finally some (possibly zero) '.'s.
The chef was devouring the festival food and was very sleepy. So his message may be invalid. You
have to help him find out if his message is valid or not using Java Programming language.
Possible input
1
18
..H..T...HTH....T.
Required Output
Transcribed Image Text:Cocullo's snake festival held on the 1st May in celebration of Saint Domenico must win awards for being not just one of Italy's strangest festivals, but also for being the most multi-cultural. The attraction of snakes seems to be a huge pull factor. The chef was tasked with reporting on the parade, so he decided to watch all the snakes first. When he sees the snake first, it will be his head, so he marks the "H". Snakes are long, and when they see the snake finally scurry away, they mark its tail with a "T". In the interim, when the snake is moving around it, or in the time between one snake and the next snake, it marks a ‘.'. Since the snakes come in a procession and one by one, a valid message would be something like "..H..T...HTH....T.", or "...", or "HT", while "T ...H..H.T", "H..T..H", "H..H..T..T" would be invalid messages (see explanation below). Formally, a snake is represented by an 'H' followed by some (possibly null) '.' and then 'T'. A valid message is one that begins with the (probably zero-length) string '!' and then some (possibly zero) snakes, with some '.'s in between, and finally some (possibly zero) '.'s. The chef was devouring the festival food and was very sleepy. So his message may be invalid. You have to help him find out if his message is valid or not using Java Programming language. Possible input 1 18 ..H..T...HTH....T. Required Output
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education