In Java please.
Posted: Fri May 20, 2022 5:44 pm
In Java please.
CHALLENGE ACTIVITY 3.8.1: If-else statement: Fix errors. 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. 373350.1838896.qx3zqy7 test passed 1 import java.util.Scanner; 2 3 public class ConvertNegative { public static void main (string [] args) { 5 Scanner scnr = new Scanner(System.in); int userNum; 4 All tests passed 6 7 8 userNum = scnr.nextInt(); V* Your solution goes here */ 99uum 10 11 12 13 } } Run
CHALLENGE ACTIVITY 3.8.1: If-else statement: Fix errors. 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. 373350.1838896.qx3zqy7 test passed 1 import java.util.Scanner; 2 3 public class ConvertNegative { public static void main (string [] args) { 5 Scanner scnr = new Scanner(System.in); int userNum; 4 All tests passed 6 7 8 userNum = scnr.nextInt(); V* Your solution goes here */ 99uum 10 11 12 13 } } Run