Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a. Function main_teleport calls the function fc_input, receiving and sending par

ID: 3821173 • Letter: A

Question

a. Function main_teleport calls the function fc_input, receiving and sending parameter to this function if needed. b. Function fc_input asks for user to type how many passengers are traveling today and if we have Solar EMP (transient electromagnetic disturbance) today {1: for yes; 0: for no); then fc_input returns the EMP condition and the number of passengers to the function main as the information was provided by the user through the keyboard. c. Function main calls the function teleport, sending the number of passenger and EMP information to function teleport; d. Inside the function teleport, if we have EMP don't go teleport in passengers and print the message "EMP expected - not teleporting today" and in such case end the program; otherwise, keep teleporting passengers until there is no passengers left; every loop subtract 1 passenger from the passenger total (passengers), printing the message e.g.: "teleporting passenger... now left passengers = 3" showing the value of the variable passengers; when passengers get equal to 0 (zero) print the message "not teleporting for now, passengers left = 0" showing the value of the variable passengers, then finish the program.

Explanation / Answer

a)

fprintf('the teleport function ');

NoOfpass=input('enter noof passengers: ');

pNo=input('enter passengernumber: ');

[p,n]=fc_input(NoOfpass,pNo);

fprintf(' number of passenger ');

disp(p);

fprintf('the passenger number ');

disp(n);

% function call

function [p,n] = fc_input(NoOfpass,pNo)

%UNTITLED3 Summary of this function goes here

%   Detailed explanation goes here

p=NoOfpass;

n=pNo;

end

b)

fprintf('the teleport function ');

SolareMP=input('Solaremp yes or no: ');

[p]=fc_input(SolareMP);

fprintf('the passenger number ');

disp(p);

% function call

function [p] = fc_input(SolareMP)

%UNTITLED3 Summary of this function goes here

%   Detailed explanation goes here

if SolareMP==1

    NOfPass=input('enter noof passenger');

p=NOfPass;

else

   p=0;

end

c)

fprintf('main function ');

pno=input('enter passengernumber:');

pname=input('enter passenger name:','s');

adress=input('enter passenger adress:','s');

[p,n,a]=teleport(pno,pname,adress);

fprintf('the passenger number ');

disp(p);

fprintf('the passenger name ');

disp(n);

fprintf('the passenger adress ');

disp(a);

%function call

function [p,n,a] = teleport(nofpass,pname,adress)

%UNTITLED3 Summary of this function goes here

%   Detailed explanation goes here

p=nofpass;

n=pname;

a=adress;

end

d)

fprintf('main function ');

totalnof=90;

pno=input('enter passengernumber:');

pname=input('enter passenger name:','s');

adress=input('enter passenger adress:','s');

reporting=input('reporting yes:1 or no:0 ');

[p,name,adresss]=teleport(pno,pname,adress,totalnof,reporting);

fprintf('the passenger number ');

disp(p);

%function call

function [p,name,adresss] = teleport(pno,pname,adress,totalnof,reporting)

%UNTITLED3 Summary of this function goes here

%   Detailed explanation goes here

if reporting==1

for i=1:totalnof

    p=pno;

    name=pname;

    adresss=adress;

    totalnumberpassengers=totalnof-1;

  

end

fprintf('now left passengers are:%d ',totalnumberpassengers);

if totalnumberpassengers==0

    fprintf('no passengers are there for reporting');

end

   

end

if reporting==0

fprintf('no passengers are reporting today');

end

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote