Page 1 of 1

NEED HELP WITH THIS MATLAB SCRIPT. I TRIED CODING IT, BUT SOMEHOW I AM GETTING INCORRECT FOR TEST CASE 1 AND 2. ALSO IT

Posted: Sun Jul 10, 2022 11:25 am
by answerhappygod
NEED HELP WITH THIS MATLAB SCRIPT. I TRIED CODING IT, BUTSOMEHOW I AM GETTING INCORRECT FOR TEST CASE 1 AND 2. ALSO IT SAYSLAST NUMBER ADDED IS WRONG. PLEASE HELP. I HAVE ALREADY SEENSOLUTIONS ON answers. I DON'T NEED THE SAME SOLUTIONS AGAIN HERE, IWILL GIVE A THUMBS DOWN IF ITS THE SAME SOLUTION.
Need Help With This Matlab Script I Tried Coding It But Somehow I Am Getting Incorrect For Test Case 1 And 2 Also It 1
Need Help With This Matlab Script I Tried Coding It But Somehow I Am Getting Incorrect For Test Case 1 And 2 Also It 1 (232.15 KiB) Viewed 33 times
A zombie picks up a calculator and starts adding odd whole numbers together, in order: 1+3+5+... etc. What will be the last number the zombie will add that will make the sum on his calculator greater than 10,000? Your task is to write the MATLAB code necessary to solve this problem for the zombie or he will eat your brain. The user should be asked to enter the target number (10,000 for example), and your code should be written in such a way that if a target number other than 10,000 is entered, the correct answer for the value entered will be determined. Script> 1% Variables to be used 2 & Inputs 3 Target the target value. 5 % Outputs 6 & lastNum - the last number added to the sum to make the total be greater than the Target value S 8 % Inputs This generates a scalar Target, replacing the user input in the following line. 10 if exist('Target', 'var') Target=randi([250]) 12 end & Target=input('Enter the target value: "); % Program Start writing your program here 16 17 num=1; 18 total=0; 19 while total<=Target 20 21 22 end Save C Reset num=num+2; total total+num; MATLAB Documentation ▶ Run Script ?
Output Target= 29 Assessment: 1 of 3 Tests Passed (20%) while Loop Check Test Case 1 The submission must contain a variable named lastNum. The last number added is incorrect. The zombie eats your brain! Feedback hidden for errors below, as these errors may be due to the initial error. Show Feedback Test Case 2 Submit 20% (20%) 0% (40%) 0% (40%) Total: 20%