Question: Math 130 I have an x mark when I input 1 for user name and two x marks when I input 99 for userName; however
Math 130


I have an x mark when I input 1 for user name and two x marks when I input 99 for userName; however my expected output is Positive. Final:99. Please help. Thank you.
Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum >0 ) System.out.println("Positive. "); else System.out. println("Non-positive, converting to 1."); userNum = 1; System.out.println("Final: " + userNum); Common student error: Changing the order of the lines. You only need to fix the existing code. Code writing challenge activity demo Common student error Your code did not have an opening brace after the else statement, but a preferred solution does so. Multiple lines must be in the same braces to be in the same branch. Testing with userNum =5 Your output Non-positive, converting to 1. Fina1: 1 Testing with userNum =99. Output differs. See highlights below. Your output Positive. Final: 1 Expected output Positive. Final: 99 Testing with userNum =1 Your output Non-positive, converting to 1. Final: 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
