+ 3

Solo learn Password validate must be build as the nested conditional. There are 3 main requitement: the password string must co

must be build as the nested conditional. There are 3 main requitements: the password string must contain minimum 2 digit decimal number in password string. If so, next it must contain minimum 2 of 7 special characters determined. If the nd requirements is fulfilled, last we have to test if it's length is between 7 and 14 characters in length (add 1 to include '\0 because I use c-style pointer based string or array of characters. Please show me the requirements of test case 5,7,9 do I can modify it accordingly to predetermined conditions. https://www.sololearn.com/discuss/2655876/?ref=app

6th Jan 2021, 10:32 PM
Oliver Pasaribu
Oliver Pasaribu - avatar
22 Antworten
+ 6
Guys what about C# and ruby
7th Jan 2021, 10:38 PM
Melekte Petros
Melekte Petros - avatar
+ 4
Oliver Pasaribu See this code (yours) I noticed that there is no validation of special characters and by the way, it seems like your answer of your first part of your code had been cut or not complete maybe because of character limits in comments in Q&A. Anyway here's the code, please update me it is still not solved. Thanks. https://code.sololearn.com/c6wiA2slBbF6/?ref=app
7th Jan 2021, 5:39 AM
noteve
noteve - avatar
+ 4
Yes, test cases are hidden even if you purchase pro. But the first and second test cases are not hidden right? Then please send the two sample input and output of the first two test cases (test case1 and test case2). And is that from Code Coach? If that is from code coach, try this: https://code.sololearn.com/crsnRg8p7o0Q/?ref=app
7th Jan 2021, 7:57 AM
noteve
noteve - avatar
+ 3
did you try length > 7 && length < 14 ?
7th Jan 2021, 4:57 AM
noteve
noteve - avatar
+ 3
It seems that nothing is wrong about the validation, I think the issue here is about the length of the string cause 3 test cases were not passed (just possible). (1) Can you specify what '/0' means? (2) Can you give some sample Inputs and Outputs? Thanks
7th Jan 2021, 7:24 AM
noteve
noteve - avatar
+ 3
Nicko12, amazing the code passes all 14 test cases from solo learn. I try to observe the difference to the earlier code, the main different is int length = strlen(password) and not length = strlen(password) -1. My code exclude null terminating character.
7th Jan 2021, 9:42 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 3
I have different opinion. I used to work or in touch with digital logic, that's why I prefer boolean-flag to direct if multi condition. We use boolean functions following c++ is-family functions which utilized flag of condition or marker widely.
7th Jan 2021, 10:20 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 3
OK. Thank you very much niko12 from Philippines. I need to check it later to convince or to ensure the for counter since I did not use '\0'null terminating char as loop termination controller.
7th Jan 2021, 10:23 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 2
/* Nested if and single if statement with 2 condition combine with operator && gives equal result. it only show simplicity and level of creativitu of programmer. please look carefully to this following nested if and single if with 2 condition combined with && operator #include <iostream> using namespace std; int main() { int a=1; int b=2; if (a==1) { if (b==2) { cout<<a<<endl; cout<<b<<endl; } else return -1; } else return -1; if ( (a==1) && (b==2) ) { cout<<a<<endl; cout<<b<<endl; } return 0; }
7th Jan 2021, 4:30 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 2
Oliver Pasaribu Yeah that was the thing (length of string) I was talking about earlier and just a suggestion, those bool data types are quite not important on short codes, I think it can be just compare it right away. And it turns out that the string must be greater than 7 and not less than 14. Anyway, you're Welcome🙂👍
7th Jan 2021, 9:45 AM
noteve
noteve - avatar
+ 2
Oliver Pasaribu Yes, I agree that it is a good practice and I just simplified it cause I'm still a beginner in c++, anyway maybe I'll do that too in my future c++ codes. Thanks.
7th Jan 2021, 10:22 AM
noteve
noteve - avatar
+ 2
Inq
7th Jan 2021, 10:32 AM
16nooralhouda355aa aa
16nooralhouda355aa aa - avatar
+ 1
Part 1 of my code Password Validator #include <iostream> #include <string> #include <cstring> using namespace std; int main() { char password[13]; int length; bool is_length_valid=0; bool is_digit_valid=0; bool is_special_character_valid=0; bool is_password_valid=0; int digitcount=0; int specialcharactercount=0; //cout<<"Please enter your password:"; cin>>password; length = strlen(password)-1; // exclude '\0' terminated character char *ptr; ptr = password; // validate if the password contains // at least 2 numerical characters for(int i=0; i<=length; i++) {if (isdigit(password[i])) ++digitcount;} // validation the presence of minimun 2 // special characters in the string if (digitcount>=2) is_digit_valid = 1; else is_digit_valid = 0; // validation the presence of minimun 2 // special characters in the string if (is_digit_valid==1) { for(int i=0; i<=length; i++) { if ( // using pointer arithnatics *(ptr+i) == '!' || *(ptr+i) == '@' || *(
7th Jan 2021, 4:52 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 1
Part 2 of my code Password Validator // validate length of password is // between 7<=length<=14 characters if (is_special_character_valid) { if (length>=7 && length<=14) is_length_valid = 1; else is_length_valid = 0; } if (is_length_valid ) is_password_valid = 1; else is_password_valid = 0; if (is_password_valid) cout<<"Strong"<<endl; else cout<<"Weak"<< endl; return 0; }
7th Jan 2021, 4:54 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 1
Sure. The length flagged by bool function is_length_valid return true if (length >=7 && length <=14). Or you can modify the if clause if (length >6 && length <15). variable into length=strlen(password)-1 to exclude character '\0'
7th Jan 2021, 5:02 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 1
This is part of code validates presenence of special characters // validation the presence of minimun 2 // special characters in the string if (is_digit_valid==1) { for(int i=0; i<=length; i++) { if ( // using pointer arithnatics *(ptr+i) == '!' || *(ptr+i) == '@' || *(ptr+i) == '#' || *(ptr+i) == '
#x27; || *(ptr+i) == '%' || *(ptr+i) == '&' || *(ptr+i) == '*' )// end if comparison ++specialcharactercount; } // end for looping if (specialcharactercount>=2) is_special_character_valid =1; else is_special_character_valid =0; } // end of is_digit_valid
7th Jan 2021, 7:04 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 1
My code does not pass solo learn test case number 5 and 7 or 5 and 9. I don't know what requirement expected from test case 5 and 7? But the requirements doesn't clearly mention if we must use nested if to test the overall conditions or. We can also use if (is_digit_valid && is_special_character_valid && is_length_valid) then password_valid = true;
7th Jan 2021, 7:46 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 1
I am not using solo learn pro.
7th Jan 2021, 7:46 AM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 1
Hi Nicko12 if I don't bother you, could you please assist me to solve the problem related to Queue Management part 2. The instruction said we have to overload operator + to enable us do operation q[n] = q[a] + q[b] ; a, b, n are constant integers or array index or array subscript. The queue itself is implemented using dynamic array using internet * queue point to heap and allocates memory for n into values.
8th Jan 2021, 12:39 PM
Oliver Pasaribu
Oliver Pasaribu - avatar
+ 1
Oliver Pasaribu I think I have not yet solved that problem but I will try to look at it and try to solve if I can. Although I suggest/recommend to post a new question about this, and show your attempt so other people that are way better than me can also help. 😊
8th Jan 2021, 12:43 PM
noteve
noteve - avatar