Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 5 . 1 6 . 1 : PRACTICE: Branches * * : Caption punctuation 7 / 1 0 A user is asked to type

25.16.1: PRACTICE: Branches**: Caption punctuation
7/10
A user is asked to type a caption for a photo in a web form's text field. If the caption didn't end with a punctuation mark (.!?), a period should automatically be added. A common error is to end with a comma, which should be replaced by a period. Another common error is to end with two periods, which should be changed to one period (however, ending with three periods (or more) indicates elipses so should be kept as is). The corrected caption is output.
If the input is "I like pie", the output is "I like pie." If the input is "I like pie!", the output remains "I like pie!" If the input is "Coming soon", the output remains "Coming soon"
Hints:
Start by checking for ! or ? which don't require any action.
Then check for , which requires the simple action of replacing by a period.
Then check for two ending periods (making sure the caption is at least 2 characters long). If found, check for three ending periods (making sure caption is at least 3 characters long), in which case no action required. Otherwise, remove the last period.
Use substring() to remove the last period.

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

1. Why do people tell lies on their CVs?

Answered: 1 week ago

Question

2. What is the difference between an embellishment and a lie?

Answered: 1 week ago