- D. H. Hepting
- CS 110
- 2 of 5
Write a program that prompts the user to enter a telephone number in the format ddd-ddd-dddd,
where d is a digit [0-9]. This is the format for telephone numbers in North America.
Test that the input is in the correct format and further check if the phone number has a
Canadian area code (see the
list of Canadian area codes
The program will report if the input is valid or not.
If the input includes a Canadian area code,
the program will display the name of the province or territory with that area code.
The program will continue to process numbers until the user enters the letter q
In addition to the correct output, as specified above,
a complete assignment will include your code in the style described and demonstrated
in the textbook with header documentation (your name, your student number, assignment number,
program name, date written, problem statement, input, output, algorithm, major variables,
assumptions, and program limitations) and inline documentation.
Output will be assessed by the markers.
5 marks according to following rubric.
Maximum grade without code (based only on output): 0.5
|Criterion and Weight
|Header Documentation (1)
- all fields meaningfully completed
- most fields meaningfully completed
- missing assumptions (eg: input should be positive)
- insufficient (eg: missing problem statement, algorithm, etc.)
- few fields, if any, completed
|Inline Documentation (1)
- comments add to understanding whole program without repeating code
- comments add to understanding most of program without repeating code
- just writing the word “calculations” instead of explaining what is being calculated and how
- more examples than logic descriptions
- Comments add to understanding some of program mostly without repeating code
- Comments, if any, do not add to understanding of the code
- meets requirements. Clear, easy to read, follows style guides
- compiles cleanly (no messages)
- meets most requirements. Readable, follows style guides
- unnecessary use of extra parentheses makes code less readable
- repetitive use of “if” statements for each condition
- the program works normally for some or all inputs that are out of range
- misunderstanding of = and ==
- compiles with some warning messages
- Meets some requirements. Mostly follows style guides
- incorrect use of basic syntax so that code may not compile
- using the word "or" instead of the logical operator OR (||)
- compiles with warning messages
Meets few requirements. Does not follow style guides.
- compile stops because of error messages
- Meets requirements. Output nicely formatted.
- Meets most requirements. Output nicely formatted.
- Meets few requirements, poorly formatted
By the due date, upload 2 files:
- your C++ program source file (likely .cpp extension)
- your log file (hercules) or screenshot (Visual Studio, XCode, etc.) that demonstrates your program's output,
using the following inputs:
- 306-585-5210 (from Saskatchewan)
- 416-123-4567 (from elsewhere in Canada)
- 305-765-5323 (valid format, not from Canada)
- 42 (not valid)
- hello (not valid)
- q (quit)