Skip to content

Programming by Design

If you're not prepared to be wrong, you'll never come up with anything original. – Sir Ken Robinson

  • About
  • Java-PbD
  • C-PbD
  • ASM-PbD
  • Algorithms
  • Other

CISS-111 BowlingEC

Posted on April 11, 2025April 11, 2025 By William Jojo
CISS-111-Project
CISS-111 Bowling Extra Credit

Write a Java program to demonstrate using regular expressions (regex) to validate strings and additional logic to validate what the regex cannot detect.

Your baseline code can be found on GitHub.


Learning outcomes

  • Working with files.
  • Enhancing existing code.
  • Working with strings and parsing.
  • Exposure to regular expressions.

Numbers

The following Java regex will help validate the provided bowling scores.

(?:[Xx]|[\-0-9][\-0-9/]){9}(?:[\-0-9]{2}|[\-0-9]/[\-0-9Xx]|[Xx][\-0-9][\-0-9/]|[Xx]{2}[\-0-9Xx])

This is explained in more detail in the Bowling Regex writeup.


Test Data

5/458/x-/x62x4/xxx=179
xxxxxxxxxxxx=300
5/4081x-/xxx4/xx/=BAD
5/4081x-/xxx4/xx5=186
xxxxxxxxxxxxx=BAD
6272348/9-xxx638/7=153
8/9-44729-xx8-359/7=133
8/9-47729-xx8-399/7=BAD
8-7-539/9/x8-513/9-=122
8-7-539191x8-51379-=122 poorly written

Your output will go to the screen. The new output will not be too much different from the original.

  5/  45  8/   x  -/   x  62   x  4/ xxx 179 179 5/458/x-/x62x4/xxx
   x   x   x   x   x   x   x   x   x xxx 300 300 xxxxxxxxxxxx
5/4081x-/xxx4/xx/ is an impossible bowling score entry.
  5/  40  81   x  -/   x   x   x  4/ xx5 186 186 5/4081x-/xxx4/xx5
xxxxxxxxxxxxx is an impossible bowling score entry.
  62  72  34  8/  9-   x   x   x  63 8/7 153 153 6272348/9-xxx638/7
  8/  9-  44  72  9-   x   x  8-  35 9/7 133 133 8/9-44729-xx8-359/7
8/9-47729-xx8-399/7 Frame 3 exceeds the limit of 10, Frame 9 exceeds the limit of 10
  8-  7-  53  9/  9/   x  8-  51  3/  9- 122 122 8-7-539/9/x8-513/9-
8-7-539191x8-51379- Frame 4 has non-standard spare marking, Frame 5 has non-standard spare marking, Frame 9 has non-standard spare marking

Submit the project to your instructor via email.

Post navigation

❮ Previous Post: Chapter x86_64-1 – The IDE

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Copyright © 2018 – 2025 Programming by Design.