Question: need help to the coding already working. 1. Create a namespace called cs135 and place all prototypes and functions implementations in the cs135 namespace. Remember,
need help to the coding already working.
1. Create a namespace called cs135 and place all prototypes and functions implementations in the cs135 namespace. Remember, you will be declaring the namespace in two locations. One for your prototypes and one for your function implementations.
2. DO NOT use the "[ ]" operator to access characters in strings. DO use the at() function instead. do not use vector
3. format the output as the photo
I paste the pa07.cpp cod here (the code already working)./// @file pa07.cpp #include
/// ------------------------------------------------------------------------- /// Function Prototype(s) /// ------------------------------------------------------------------------- bool ValidInput(std::string line); bool CheckSum(std::string number, int caseNum);
using namespace std;
int main() { const string filename = "pa07-input0data.txt"; ifstream inputfile(filename);
if (inputfile.is_open()) { string line; int caseNum = 1; while (getline(inputfile, line)) { CheckSum(line, caseNum); caseNum++; } inputfile.close(); } else { cout
return 0; } /// ------------------------------------------------------------------------- /// Function Implementation(s) /// ------------------------------------------------------------------------- bool ValidInput(string line) { // Remove all dashes and spaces from the line string strippedLine = ""; for (char c : line) { if (c != ' ' && c != '-') { strippedLine += c; } }
// Check if line is a 10-digit number with optional 'A' at the end bool isValid = true; if (strippedLine.length() != 10 && strippedLine.length() != 11) { isValid = false; } else { for (int i = 0; i
return isValid; } bool CheckSum(string number, int caseNum) { // Remove any dashes or spaces string strippedNumber = ""; for (char c : number) { if (c != ' ' && c != '-') { strippedNumber += c; } }
// Check that number is valid if (!ValidInput(strippedNumber)) { cout
// Convert digits to ints and store in vector vector // Calculate check digit int checkDigit = 0; for (int i = 0; i // Check if check digit is valid if (checkDigit % 11 != 0) { cout // If everything checks out, the number is valid cout 

Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
