Giter Club home page Giter Club logo

stage0-module4-conditions-task4's Introduction

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) {
    }
}

stage0-module4-conditions-task4's People

Contributors

sukora-stas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.