Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) System.out.prin

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) System.out.prin

Post by answerhappygod »

Re Type The Code And Fix Any Errors The Code Should Convert Non Positive Numbers To 1 If Usernum 0 System Out Prin 1
Re Type The Code And Fix Any Errors The Code Should Convert Non Positive Numbers To 1 If Usernum 0 System Out Prin 1 (26.86 KiB) Viewed 41 times
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. 400512.2468666.qx3zqy7 1 import java.util.Scanner; 2 3 public class ConvertNegative { 4 public static void main (String[] args) { 5 Scanner scnr = new Scanner(System.in); int userNum; userNum = scnr.nextInt (); in 1000 a 6 7 8 9 10 11 12} T }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply