Thread: can anyone solve this problem for me

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    9

    Smile can anyone solve this problem for me

    can anyone solve this problem for me

    I need help with this problem can you solve it for me ( write the program)



    -A password-protected security door can only be opened when a user inserts a valid 4-digit personal identification number (PIN).
    -The program starts by asking the user to enter a 4-digit PIN.If it is valid, the locked door is opened and the program returns for another user
    input. If, on the other hand, the PIN is invalid the program checks whether three attempts were made. If so, the alarm is triggered; otherwise the user is given another try to input the correct PIN.
    -Assume that your security door system supports 10 users each with a unique PIN.


    and i'll BE THANKFULL

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    No we can't - read the forum rules.
    This isn't a homework on demand service.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    9
    it's not homework,

    i have a final exam and this question was in one of the final exam sample
    i just want to know how to solve it.

    hope you can help.

  4. #4
    Registered User
    Join Date
    May 2012
    Posts
    9
    i already done the problem i just need help i dont it only for one user and here is the code i just need it for 10 i cant do it

    // Password-Protected Security Door
    Code:
    #include <iostream>
    using namespace std;
    
    void main()
    {
    int pin=1111;
    
    int pin2=0;
    int cont=0;
    
    while(cont<3)
    {
    if (pin2==0)
    {
    std::cout << "please enter your pin number\n" ;
    std::cin >> pin2;
    }
    if ( pin==pin2)
    {
    std::cout << "Door opens\n" ;
    cont=4;
    
    }
    else
    {
    cont++;
    pin2=0;
    }
    if (cont==3)
    { std::cout << "Alarm\n" ;
    }
    }
    }

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Hint: use an array to store a list of valid PIN numbers. Then, loop over the array to check of the user input matches any of them.

    Also, you should indent your code properly and specify the return type of main as int, not void.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #6
    Registered User
    Join Date
    May 2012
    Posts
    9
    Quote Originally Posted by laserlight View Post
    Hint: use an array to store a list of valid PIN numbers. Then, loop over the array to check of the user input matches any of them.

    Also, you should indent your code properly and specify the return type of main as int, not void.
    thanks for hint but really i'm a beginners and need help i want to get a good grade out at the end of the semester.

  7. #7
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by s000p222 View Post
    ...but really i'm a beginners and need help i want to get a good grade out at the end of the semester.
    What exactly do you need help with ?
    Did you try to do what laserlight suggested ?
    If so, post your code.

  8. #8
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    We can't take your test for you. Laserlight gave a good hint... you might want to revisit the array and loop structure part of your textbook so that you understand what he's suggesting. And you might do better on the test in general.

  9. #9
    Registered User
    Join Date
    May 2012
    Posts
    9
    I'll try thanks all for the support.
    if i have something i'll let you know.

    BIG THANKS TO YOU ALL.
    WISH ME LUCK...

  10. #10
    Registered User
    Join Date
    May 2012
    Posts
    9
    thanks alot lads,
    I'm here to learn first. i really learned alot from you now, i understand the arrays and loops
    i know what they do but my problem is writing the program i'm good at the theory part but at tutorial that my difficulty.

    I will apreciat it if you can write me the progrom or a program similar to it so i can see how it's written.
    thanks again lads BIG TIME.

  11. #11
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Congrats, you are already in step 3.5 !
    5 1/2 steps to get others to doing your homework
    Virtual cookies if you can get to 5b ...before the thread is closed.
    Last edited by manasij7479; 05-30-2012 at 07:09 AM.

  12. #12
    Registered User
    Join Date
    May 2012
    Posts
    9
    Quote Originally Posted by manasij7479 View Post
    Congrats, you are already in step 3.5 !
    5 1/2 steps to get others to doing your homework
    Virtual cookies if you can get to 5b ...before the thread is closed.
    first i'm here to learn thats why i'm here if you dont want to help that's ok, but don't come and say this and that
    it's not a homework i'm not at school. and this is for my finals i want to know how to solve this kind of problems
    they can solve any similar one i don't care. I JUST WANT TO LEARN

  13. #13
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by s000p222 View Post
    I will apreciat it if you can write me the progrom or a program similar to it
    I don't think you can afford my hourlies...
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  14. #14
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    it's not a homework i'm not at school. and this is for my finals
    Isn't this contradictory? Or are you trying to say you're just not physically at the school at this moment. Because obviously that would make a big difference.

    Also begging here

  15. #15
    Registered User
    Join Date
    May 2012
    Posts
    9
    OK ok all i'm sorry i apoligize but god with all this negativity.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to solve this problem?
    By lijr07 in forum C++ Programming
    Replies: 13
    Last Post: 07-30-2011, 12:53 PM
  2. Please help me to solve this IO problem.
    By nichya88 in forum C++ Programming
    Replies: 2
    Last Post: 01-19-2010, 12:15 PM
  3. how do i solve this problem?
    By manav in forum A Brief History of Cprogramming.com
    Replies: 31
    Last Post: 04-15-2008, 09:58 AM
  4. Can someone solve this problem for me?
    By hykyit in forum C Programming
    Replies: 2
    Last Post: 03-17-2005, 02:57 AM
  5. problem cant solve please help.
    By sarah in forum C Programming
    Replies: 6
    Last Post: 09-03-2001, 01:32 PM