Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given a string S consisting of N characters. The string is a valid phone number if it consists of three segments of digits

You are given a string S consisting of N characters. The string is a valid phone number if it consists of three segments of digits (each three digits long) separated by sing dashes. Write a function: bool solution(string &5); that, given a string S of length N, returns true if the string S represents a valid phone number and false if it doesn't. Examples: 1. Given string S="123-123-123", the function should return true. 2. Given string S123123123", the function should return false, because the segments are separated by spaces instead of dashes. 03. Given string S="123-123-1234", the function should return false, because there are too many digits in the last segment. 4. Given string S001-501-511", the function should return

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Explain the pages in white the expert taxes

Answered: 1 week ago

Question

3. Comment on how diversity and equality should be managed.

Answered: 1 week ago

Question

describe the legislation that addresses workplace equality

Answered: 1 week ago