public class QuestionTest
{
public static void main(String[] args)
{
String test;
int num1 = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
num1 = 5;
test = num1 > 0 ? "Positive" : "Negative";
System.out.println(test);
num2 = 6;
test = num2 > 0 ? "Positive" : "Negative";
System.out.println(test);
num3 = -3;
test = num3 > 0 ? "Positive" : "Negative";
System.out.println(test);
num4 = 78;
test = num4 > 0 ? "Positive" : "Negative";
System.out.println(test);
test = num1 > 0
? num2 > 0
? num3 > 0
? num4 > 0
? "All numbers are positive"
: "Num4 isn't positive"
: "Num3 isn't positive"
: "Num2 isn't positive"
: "Num1 isn't positive";
System.out.println(test+"\n"); //Only num3 is negative. num1 = 5; test = num1 > 0 ? "Positive" : "Negative"; System.out.println(test); num2 = 6; test = num2 > 0 ? "Positive" : "Negative"; System.out.println(test); num3 = 3; test = num3 > 0 ? "Positive" : "Negative"; System.out.println(test); num4 = 78; test = num4 > 0 ? "Positive" : "Negative"; System.out.println(test); test = num1 > 0 ? num2 > 0 ? num3 > 0 ? num4 > 0 ? "All numbers are positive" : "Num4 isn't positive" : "Num3 isn't positive" : "Num2 isn't positive" : "Num1 isn't positive"; System.out.println(test); //All numbers are positive. } }
? num2 > 0
? num3 > 0
? num4 > 0
? "All numbers are positive"
: "Num4 isn't positive"
: "Num3 isn't positive"
: "Num2 isn't positive"
: "Num1 isn't positive";
System.out.println(test+"\n"); //Only num3 is negative. num1 = 5; test = num1 > 0 ? "Positive" : "Negative"; System.out.println(test); num2 = 6; test = num2 > 0 ? "Positive" : "Negative"; System.out.println(test); num3 = 3; test = num3 > 0 ? "Positive" : "Negative"; System.out.println(test); num4 = 78; test = num4 > 0 ? "Positive" : "Negative"; System.out.println(test); test = num1 > 0 ? num2 > 0 ? num3 > 0 ? num4 > 0 ? "All numbers are positive" : "Num4 isn't positive" : "Num3 isn't positive" : "Num2 isn't positive" : "Num1 isn't positive"; System.out.println(test); //All numbers are positive. } }