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

i need the solutions for q#1 and q#2 please rouernse 20Fall%202017-1.pdf 1. Writ

ID: 2265633 • Letter: I

Question

i need the solutions for q#1 and q#2 please

rouernse 20Fall%202017-1.pdf 1. Write a script that will print the tollowing multiplication table. (30 points) 8 10 9 12 15 16 20 2. Long distance swimmers desire to find out their average speed based on their estimated completion time for a 4-mile swimming distance (The world record is about I hour 30 minutes). Write a function called SwimmingRecord that will accept a vector of different swimmers' target completion times in whole number of minutes. The function returns a vector of the average speed in mile per hour for each completion time and prints the average speed (in mile per hour) for each swimmer. Call your function for a vector argument of at least five different completion times and assign the returned value to a variable called AverageSpeed. Your function should do error check for non-whole and negative numbers. (30 points)

Explanation / Answer

The question doesnot mention which type of script is required. I have assumed the script to be in MATLAB and written the solutions according to MATLAB script format. If you had expected the script in some other language. Kindly look into the solutions, the structure of the solution provide enough information to port the solution into any other language.

q#1: The multiplication table prints based on the number inputted as an argument. MATLAB function is written below with a few comments to check for whole number and negative numbers.

----- BEGIN OF MATLAB CODE -----------

% Print multiplication table

function printMultiplication(n)

% Check for negative number

if(n < 0)

disp('The input number is negative');

return

end

% Check for whole integer

if((n - floor(n)) ~= 0)

disp('The input number is not whole number');

return

end

for i=1:n

disp(n*i);

end

end

------------------- END OF MATLAB CODE -----------------------------

q#2: Swimming function is written in MATLAB. The function takes a vector as input argument and checks each element for negatives and non whole numbers before performing the calculation of average speed.

------------------------------- BEGIN OF MATLAB CODE --------------------------

function AverageSpeed = SwimmingRecord(s)

% Check the number of elements in the vector 's'

N = length(s);

AverageSpeed = 0;

if(N < 5)

disp('Less number of completion times in the input vecor');

return

end

for i=1:N

% Check for negative number

if(s(i) < 0)

disp('The input vector has negative completion time');

return

end

% Check for whole integer

if((s(i) - floor(s(i))) ~= 0)

disp('The input vector has non whole number as completion time');

return

end

end

AverageSpeed = mean(s)/60; % Completion times will be in minuter, dividing by 60 converts it to mph

end

------------------------ END OF MATLAB CODE -------------------------

I hope that the solutions provided here helps you to write the script in a language other than MATLAB.