Answer to Question #188820 in C++ for artz

Question #188820

Write a function that tests to see if a string constants a valid Rhode Island drivers license number. A Rhode Island drivers license meets one of the two criteria

  • contains 7 Numeric
  • 1 Alpha and 6 Numeric characters. 
1
Expert's answer
2021-05-04T01:54:40-0400
#include <iostream>
using namespace std;
int main(){
    int countA = 0, countN = 0;
    cout<<"Enter number plate;\n";
    string s; cin>>s;
    for(int i = 0; i < s.length(); i++){
        if(s[i] >= '0' && s[i] <= '9') countN++;
        else if(s[i] >= 'A' && s[i] <= 'Z') countA++;
        else if(s[i] >= 'a' && s[i] <= 'z') countA++;
    }
    if(countA == 1 && countN == 6) cout<<"Valid Rhode Island driving licence number";
    else cout<<"Not a valid Rhode Island driving licence number";
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS