In: Electrical Engineering
MATLAB: Create your own problem in words that use loop and selection statements in the same problem. Create a problem that has a somewhat practical, real-life application like entering your PIN code at an ATM, and then after 4 incorrect tries, you are locked out of the ATM. Or create a problem based perhaps upon a physics or chemistry lab.
The problem should require the use of a WHILE loop, a FOR loop and a minimum of 3 selection statements [IF].
PROBLEM:ATM MACHINE
Inputs:
  
    1.PIN number (setting pin number)
    2.Balance    (Initial balance)
    3.wanting a transaction  (y/n)
       
          if yes
                i. balance enquiry
               ii. credit balance
              iii. redeem money from account
in all the cases it will asks for pin number and shows remaining balance.
after  the transaction it will ask for another transaction.
============================================
pin = input('set the pin number. :');
bal = input('Enter the initial account balance. :');
tran = input('want to do a transaction (y/n): ','s');
while(tran=='y')
    valid = 0;
    disp('1.balance enquiry \t 2.add an amount \t3.take an amount :');
    sel = input('Select any of the above transactions (1,2,3) :');
    for i=1:3
        if(i==1)
         pin1 = input('Enter pin Number :');
        else
         pin1 = input('Enter correct pin Number :');   
        end
         if pin1==pin
                 valid = 1;
                 break
         end
    end
    if(valid ==1 )
        if(sel==1)
            disp('Your current balance is :');
            disp(bal)
        elseif sel==2
            amount = input('enter the amount :');
            bal=bal+amount;
            disp('Your current balance is :');
            disp(bal)
        elseif sel==3
            amount = input('enter the amount :');
            bal=bal-amount;
            disp('Your current balance is :');
            disp(bal)
        end
        tran = input('want to do a transaction (y/n): ','s');
    else
        disp('sorry you have entered wrong pin for 3 times');
        tran='n';
    end
        
   
end