### Speeding Ticket Algorithm If you are driving over the speed limit, a police officer stops you. This algorithm provides a way to determine the outcome based on your speed and whether it is your birthday. The results are encoded as an integer: - **0**: No ticket - **1**: Small ticket - **2**: Big ticket #### Conditions: 1. **Speed is 60 or less**: - Result is 0. 2. **Speed is between 61 and 80 inclusive**: - Result is 1. 3. **Speed is 81 or more**: - Result is 2. 4. **Birthday Rule**: - If it is your birthday, your allowed speed increases by 5 in all cases. #### Examples: - `speeding(60, false) -> 0` - `speeding(65, false) -> 1` - `speeding(65, true) -> 0` **Parameters:** - `speed`: Your driving speed. - `isBirthday`: True if it is your birthday. **Return**: The result as described. ### String Pattern Detection This algorithm checks if a given string contains a pattern similar to "pop", where the 'o' character in the middle can be any character. #### Examples: - `popThere("abcpop") -> true` - `popThere("p9p") -> true` - `popThere("paa") -> false` Write the methods for both functionalities to implement these checks.
### Speeding Ticket Algorithm If you are driving over the speed limit, a police officer stops you. This algorithm provides a way to determine the outcome based on your speed and whether it is your birthday. The results are encoded as an integer: - **0**: No ticket - **1**: Small ticket - **2**: Big ticket #### Conditions: 1. **Speed is 60 or less**: - Result is 0. 2. **Speed is between 61 and 80 inclusive**: - Result is 1. 3. **Speed is 81 or more**: - Result is 2. 4. **Birthday Rule**: - If it is your birthday, your allowed speed increases by 5 in all cases. #### Examples: - `speeding(60, false) -> 0` - `speeding(65, false) -> 1` - `speeding(65, true) -> 0` **Parameters:** - `speed`: Your driving speed. - `isBirthday`: True if it is your birthday. **Return**: The result as described. ### String Pattern Detection This algorithm checks if a given string contains a pattern similar to "pop", where the 'o' character in the middle can be any character. #### Examples: - `popThere("abcpop") -> true` - `popThere("p9p") -> true` - `popThere("paa") -> false` Write the methods for both functionalities to implement these checks.
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
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 1 images
Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education