C++ need help !

Discuss about Programming here. You may release your source, post guide and even ask questions!

Moderator: wizme

Post Reply
lemonnutz
Apprantice Knight
Apprantice Knight
Posts: 6
Joined: Wed Apr 14, 2010 10:05 am

C++ need help !

Post by lemonnutz »

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
Image
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ need help !

Post by Nerrazzuri »

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.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
lemonnutz
Apprantice Knight
Apprantice Knight
Posts: 6
Joined: Wed Apr 14, 2010 10:05 am

Re: C++ need help !

Post by lemonnutz »

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();

><
Image
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ need help !

Post by Nerrazzuri »

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.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
lemonnutz
Apprantice Knight
Apprantice Knight
Posts: 6
Joined: Wed Apr 14, 2010 10:05 am

Re: C++ need help !

Post by lemonnutz »

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 :)
Image
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ need help !

Post by Nerrazzuri »

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 :)
lol, you are not getting what I meant, just forget about it. Hope someone will help you soon.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
SoullessSoul
The Great Lord
The Great Lord
Posts: 1036
Joined: Sun Feb 07, 2010 3:32 am
Location: Lost WorlD

Re: C++ need help !

Post by SoullessSoul »

LOL wad Nerrazzuri mean is show us your script ==''
Image
ShiunYean
Headmaster of Darkness
Headmaster of Darkness
Posts: 648
Joined: Tue Sep 08, 2009 2:59 pm
Location: Brunei Darussalam
Contact:

Re: C++ need help !

Post by ShiunYean »

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;
}
}
happy125
Headmaster of Darkness
Headmaster of Darkness
Posts: 549
Joined: Tue Jun 22, 2010 10:06 pm
Location: Singapore

Re: C++ need help !

Post by happy125 »

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;
}
}
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.
If ur good at smth, never do it for free.
Maple ID list v1.02
Image
Image
Image
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ need help !

Post by Nerrazzuri »

Some idea you can use.

Code: Select all

if (str[i] >= 0x30 && str[i] <= 0x39) continue; //0-9
if (str[i] >= 0x41 && str[i] <= 0x5A) continue; //A-Z
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.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
Post Reply