C++ need help !
Moderator: wizme
C++ need help !
Guys.. I need help for my project >< i cant solve it ><
Question is ->
"Write a program to enter ask user to enter a 6 to 10 character password. Print valid
if the password has at least two digits, one upper case letter, one punctuation sign and the first letter start with 6. If invalid, print an error message to explain to the user why it is invalid."
punctuation sign mean symbol eg. [~!@#$%^&*()_]
i really cant think of any code can solve this question >< hope you guys might help me TT
Question is ->
"Write a program to enter ask user to enter a 6 to 10 character password. Print valid
if the password has at least two digits, one upper case letter, one punctuation sign and the first letter start with 6. If invalid, print an error message to explain to the user why it is invalid."
punctuation sign mean symbol eg. [~!@#$%^&*()_]
i really cant think of any code can solve this question >< hope you guys might help me TT

- Nerrazzuri
- Destiny General
- Posts: 1110
- Joined: Sun Dec 20, 2009 9:15 pm
Re: C++ need help !
Why don't you show us what have you done?
This isn't hard, and I can give the solution to you but if you're just requesting something that you're lazy to do, then sorry.
This isn't hard, and I can give the solution to you but if you're just requesting something that you're lazy to do, then sorry.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot
Click Here for more Information!

Click Here for more Information!

Re: C++ need help !
i am new to c++ ><
but i could not think of the code tat how to let the cin value must contain those requirement ..
i made myself the code...but is wrong...so i delete it ...
i still remember with using #include <cstring>, and the cin i use cin.getline();
><
but i could not think of the code tat how to let the cin value must contain those requirement ..
i made myself the code...but is wrong...so i delete it ...
i still remember with using #include <cstring>, and the cin i use cin.getline();
><

- Nerrazzuri
- Destiny General
- Posts: 1110
- Joined: Sun Dec 20, 2009 9:15 pm
Re: C++ need help !
You are requesting someone to help you finish your work, and that will not be me. If you want someone to help you, show your unfinished work and we will try to fix it for you.
Tips: use standard string and check using a loop.
Tips: use standard string and check using a loop.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot
Click Here for more Information!

Click Here for more Information!

Re: C++ need help !
ya..is my un-finish work..coz i don't know how to do ==!! what you want me to do? what you expect for?
i cant complete my work coz i really don't HOW to do..so i just ask at here...
well..is too sad u don't want to help..is ok
i cant complete my work coz i really don't HOW to do..so i just ask at here...
well..is too sad u don't want to help..is ok


- Nerrazzuri
- Destiny General
- Posts: 1110
- Joined: Sun Dec 20, 2009 9:15 pm
Re: C++ need help !
lol, you are not getting what I meant, just forget about it. Hope someone will help you soon.lemonnutz wrote:ya..is my un-finish work..coz i don't know how to do ==!! what you want me to do? what you expect for?
i cant complete my work coz i really don't HOW to do..so i just ask at here...
well..is too sad u don't want to help..is ok
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot
Click Here for more Information!

Click Here for more Information!

-
- The Great Lord
- Posts: 1036
- Joined: Sun Feb 07, 2010 3:32 am
- Location: Lost WorlD
-
- Headmaster of Darkness
- Posts: 648
- Joined: Tue Sep 08, 2009 2:59 pm
- Location: Brunei Darussalam
- Contact:
Re: C++ need help !
Here's the code he sent to my pm on facebook:
Code: Select all
#include <iostream>
using namespace std;
void main()
{
int digit1=2,digit2=10,o;
char letter1=0,str2[11],len2;
for ( o=0; o < len2; o++ )
len2=strlen(str2);
cout<<"Please enter 6 to 10 character as password.Note that password must contain 2 digit,1 upper-case character,1 punctuation"<<endl;
cin.getline(str2,11);
if(str2[o]<digit1 && str2[o]>digit2 && str2[o]>len2){
cout<<"invalid"<<endl;
}else{
cout<<"valid"<<endl;
}
}
Re: C++ need help !
his for loop no open bracket, never return 0, i recommend just using 2 and 10 in place of digit1/2. use variables such as 'i' or 'x' instead of o as its confusing.ShiunYean wrote:Here's the code he sent to my pm on facebook:Code: Select all
#include <iostream> using namespace std; void main() { int digit1=2,digit2=10,o; char letter1=0,str2[11],len2; for ( o=0; o < len2; o++ ) len2=strlen(str2); cout<<"Please enter 6 to 10 character as password.Note that password must contain 2 digit,1 upper-case character,1 punctuation"<<endl; cin.getline(str2,11); if(str2[o]<digit1 && str2[o]>digit2 && str2[o]>len2){ cout<<"invalid"<<endl; }else{ cout<<"valid"<<endl; } }
- Nerrazzuri
- Destiny General
- Posts: 1110
- Joined: Sun Dec 20, 2009 9:15 pm
Re: C++ need help !
Some idea you can use.
this is to check if the current str has the same keycode as in the condition loop. If it is the same, the continue then loop without looking to the code bottom.
Code: Select all
if (str[i] >= 0x30 && str[i] <= 0x39) continue; //0-9
if (str[i] >= 0x41 && str[i] <= 0x5A) continue; //A-Z
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot
Click Here for more Information!

Click Here for more Information!
