C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-08-2009, 10:06 AM   #1
Registered User
 
Join Date: Nov 2009
Posts: 1
need some help

i have been asked to solve the following problem

Make a list of pin numbers. Prompt a user for his pin number. If he has entered a valid pin number it, display the message “Welcome to the system. Your pin number is verified”. After that it should give the user options to check his balance as well. If it is not among the valid pin number list, display that “your pin is not verified”. Ask user to enter again. One user can try only 3 times. the program should not get crashed if a character is entered instead of a number.not allowed to use any loops , use only variables

i did some coding but i am stuck on how to make the program work in the three invalid tries area...and also the program crashes if i use a character



#include<iostream.h>

void main()
{
int a,b,c,d,e,f,g,h,i,j,pin,x,y;

a=1234;
b=2345;
c=5321;
d=5674;
e=8753;
f=1237;
g=9456;
h=3467;
i=9128;
j=5190;
x=0;




cout<<"Enter the pin number :";
cin>>pin;


if((x=0) && (pin==a||pin==b||pin==c||pin==d||pin==e||pin==f||p in==g||pin==h||pin==i||pin==j))
{
cout<<"Welcome to the system. Your pin number is verified"<<endl;
cout<<"check your balance"<<endl;
}
else if (pin!=a||pin!=b||pin!=c||pin!=d||pin!=e||pin!=f||p in!=g||pin!=h||pin!=i||pin!=j)


{ cout<<"your pin is not verified"<<endl;
cout<<"Enter the pin number :";
cin>>pin;
x++;
}
if

((x=1) && (pin==a||pin==b||pin==c||pin==d||pin==e||pin==f||p in==g||pin==h||pin==i||pin==j))
{
cout<<"Welcome to the system. Your pin number is verified"<<endl;
cout<<"check your balance"<<endl;
}

else if (pin!=a||pin!=b||pin!=c||pin!=d||pin!=e||pin!=f||p in!=g||pin!=h||pin!=i||pin!=j)

{ cout<<"your pin is not verified"<<endl;
cout<<"Enter the pin number :";
cin>>pin;
x++; }
if

((x=2) && (pin==a||pin==b||pin==c||pin==d||pin==e||pin==f||p in==g||pin==h||pin==i||pin==j))
{
cout<<"Welcome to the system. Your pin number is verified"<<endl;
cout<<"check your balance"<<endl;
}
else if (pin!=a||pin!=b||pin!=c||pin!=d||pin!=e||pin!=f||p in!=g||pin!=h||pin!=i||pin!=j)

{ cout<<"your pin is not verified"<<endl;
cout<<"Enter the pin number :";
cin>>pin;
x++; }
}
wraithlord is offline   Reply With Quote
Old 11-08-2009, 10:44 AM   #2
Registered User
 
Join Date: Oct 2006
Posts: 263
well, first things first you need to do the following in the order specified:

1. think of a better thread title than "need some help". it's very non-descriptive, and doesn't give the reader any idea what you need help with.

2. put code tags around your code so that it shows up formatted properly.

now, on to your problem.

my first suggestion would be to put all of the valid PINs in an array such as:
Code:
int pin_array[] = { 1234, 2345, 5321, 5674, 8753, 1237, 9456, 3467, 9128, 5190 };
perhaps you could have some kind of identifier at the end of the array (such as -1) to indicate that it's the end. then you can loop through the array until you find the identifier, and break out of the loop when the identifier is found. if the PIN the user entered is found inside the loop, you can give feedback to the user that it was found. if not, tell them that they entered an invalid PIN.
Elkvis is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump


All times are GMT -6. The time now is 07:48 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22