Paracells / stage0-module4-conditions-task4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tasks:

1. Greatest from 3.

Implement the program that will consume 3 numbers from method arguments and it will print the print greatest out of three. In case if there are more than 1 biggest -> print any of them.(Libraries are forbidden)

public class MaxNumberPrinter {
    public void printGreatest(int first, int second, int third) {
    }
}

2. Ternary operator.

Complete the statement below so as to make it compile and print 23 (using ternary operator):

public class TernaryOperator {
    public static void main(String[] args) {
        int b = 16;
        b = b __ 0 ? 10 : 23;
        System.out.println(b);
    }
}

3. Ternary greatest from 2.

Rewrite Greatest number printer task from module 4.1 Task # 2 using rewrite some task with ternary operator:

    public class TernaryGreatestNumberPrinter {
        public void printGreatest(int first, int second) {
        }
    }

4. Ternary printer.

Implement the program that will consume 2 numbers and based on their comparison will print to console which is bigger. Comparison should be implemented with ternary operator, which should be used inside of System.out.println method.(print "first", if the first is bigger and "second" in the rest cases). System.out.println should be used only 1 time

public class TernaryPrinter {
    public void printWhichIsBigger(int first, int second) {
    }
}

5. Ternary assignment.

Create a variable "int result" and dependent on the result comparison of 2 variables from method arguments and the assign to the created variable the value using ternary result: if the first is bigger -> 10 otherwise -10. And print result variable.

    public class TernaryAssignment {
        public void assignAndPrintBasedOnWhichBigger(int first, int second) {
        }
    }

6. Ternary greatest from task 1.

Rewrite "1. Greatest from 3." from this task using ternary operator

 public class TernaryMaxNumberPrinter {
    public void printGreatest(int first, int second, int third) {
    }
}

About


Languages

Language:Java 100.0%