Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

LO5 Highlight five external recruiting sources.

Answered: 1 week ago