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
#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;
}
Comments
Leave a comment