Question: The first answer should be ans = 0, ans1 = 0 because the input is odd number, but I think they ignored case condition. Which



The first answer should be ans = 0, ans1 = 0 because the input is odd number, but I think they ignored case condition.
Which part do I need to fix my code?
Function Name: doubleOrNothing Inputs: - (double) a positive number Output: - (double) a number based on the input Description: - Write a function called doubleOrNothing that takes in a positive number and outputs a modified value. If the input is an even number, output two times the input value. Otherwise, output 0. - You MUST use SWITCH statements. Examples: ans1 = doubleorNothing(5) %>> ans 1=0 ans2 = doubleorNothing (100) %> ans 2=200 ans 3= doubleorNothing (8) % ans 3=16 \begin{tabular}{|l|c|} \hline 1 & function ans = doubleorNothing(num) \\ 2 & switch num \\ 3 & case mod( num, 2) ==1 \\ 4 & ans =0 \\ 5 & otherwise \\ 6 & ans =2 num \\ 7 & end \end{tabular} ans= 10 ans1 = 10 ans = 200 ans 2= 200 ans = 16 ans3= 16
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
