Answered step by step
Verified Expert Solution
Link Copied!

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... 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

Building Java Programs A Back To Basics Approach

Authors: Stuart Reges, Marty Stepp

5th Edition

013547194X, 978-0135471944

More Books

Students also viewed these Programming questions

Question

Write a program called Egg that displays the following output:

Answered: 1 week ago

Question

What types of business entities does our tax system recognize?

Answered: 1 week ago