Identify a positive value for parameter d that will cause this method to print "green", but not any of the other colors when executed.
public static void ifelse(int d) { if (d >= 12.5) { System.out.println("blue"); } else if (d % 3 == 0) { System.out.println("yellow"); } else if (d < 10) { System.out.println("green"); } if (d > 6) { System.out.println("red"); } }
Identify a positive value for parameter d that will cause this method to print "green", but not any of the other colors when executed.
public static void ifelse(int d) { if (d >= 12.5) { System.out.println("blue"); } else if (d % 3 == 0) { System.out.println("yellow"); } else if (d < 10) { System.out.println("green"); } if (d > 6) { System.out.println("red"); } }
There will be 4 positive value for parameter d that will cause this method to print "green", but not any of the other colors when executed values are 1,2,4,5 because they are less than 12.5 and 6 and they modulo by 3 will never be zero then only one condition will be true that is d<10 and only "green" will be printed.
Make sure to hit the like button if you find this helpful for you THANK YOU AND HAPPY LEARNING!!
Get Answers For Free
Most questions answered within 1 hours.