Question

In: Electrical Engineering

MATLAB: Create your own problem in words that use loop and selection statements in the same...

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].

Solutions

Expert Solution

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

        
    
    
    

Related Solutions

Note: Use your own words and be sure to support your statements with logic and arguments....
Note: Use your own words and be sure to support your statements with logic and arguments. Question: Recognize how changes in supply and demand affect market outcomes and explain the effect of government regulation on prices.
Discussion 1 - Use your own words and be sure to support your statements with logic...
Discussion 1 - Use your own words and be sure to support your statements with logic and arguments. Post your comments Q1- Recognize how changes in supply and demand affect market outcomes and explain the effect of government regulation on prices? Q2- Students are required to reply to at least two peer responses to this week’s discussion question. ((((These answers students, I want you to answer the first and second answers))) 1-Demand is an inverse relationship between the quantity of...
In your own words (you cannot paraphrase), explain the adverse selection problem that car insurance companies...
In your own words (you cannot paraphrase), explain the adverse selection problem that car insurance companies face and how they deal with it. Finally, in few words explain whether insurance companies should only insure safe drivers.
In your own words describe what your thoughts are on culture and mate selection
In your own words describe what your thoughts are on culture and mate selection
Problem 4 ..... you can use Matlab Using the same initial code fragment as in Problem...
Problem 4 ..... you can use Matlab Using the same initial code fragment as in Problem 1, add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR bandstop filter with band edge frequencies 750 Hz and 850 Hz and based on a 4th order Butterworth prototype. Name your program p3.sce the below is the Problem 1 initail code .. you can use it Matlab The following cilab code generates a 10-second “chirp”...
Create your OWN GOMS technique model. (Goals, operators, methods and selection)
Create your OWN GOMS technique model. (Goals, operators, methods and selection)
Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in...
Use MATLAB to create a script which solves for problem 5.9 in the book (5.11 in the 4th edition). Given are the equations for the moment, as a function of x, starting from the leftmost side of the beam with x=0 and ending at the other end of the beam with x=12. This piecewise function together makes up the moment equation for the beam given. 0 ≤ ? ≤ 3 ?(?) = 265? − 5.56?3 , 3 < ? ≤...
Describe and discuss in your own words adolescent sexuality. Use own words please
Describe and discuss in your own words adolescent sexuality. Use own words please
4) Explain in your own words the Knowledge Problem. How would you use the insights of...
4) Explain in your own words the Knowledge Problem. How would you use the insights of the Economic Calculation Problem to understand an event that you have observed in your life, an event from the news, or an event in your life?
In your own words, describe the problem solving strategy you would use to find an unknown...
In your own words, describe the problem solving strategy you would use to find an unknown force in a mechanical system
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT