Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) else System.out.println(Positive.); System.out.println(Non-positive, converting to
Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) else System.out.println("Positive."); 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. 1 import java.util.Scanner; 2 7689SSDWNA 3 public class ConvertNegative { 4 public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int userNum; 5 10 11 TTT TIL 12 13 System.out.println("Non-positive, 14 56700 userNum = 1; 15 System.out.println("Final: 16 17 userNum scnr.nextInt (); if (userNum > 0) System.out.println("Positive."); 18 } else } converting to 1."); + userNum); /* Your solution goes here */
Step by Step Solution
★★★★★
3.45 Rating (158 Votes )
There are 3 Steps involved in it
Step: 1
The detailed answer for the above question is provided below Answer Here is the correcte...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