- 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 40 times
Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) System.out.prin
-
- 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
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 }