Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started