{"id":73,"date":"2015-07-17T11:13:47","date_gmt":"2015-07-17T08:13:47","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=73"},"modified":"2015-07-20T12:58:06","modified_gmt":"2015-07-20T09:58:06","slug":"2min","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=73","title":{"rendered":"Find the minimum of two numbers"},"content":{"rendered":"<p><strong>Task<\/strong>. Were given two real numbers [latex]x[\/latex] and [latex]y[\/latex]. Find [latex]\\min (x, y)[\/latex].<\/p>\n<h1>Tests<\/h1>\n<table border=\"2\">\n<tbody>\n<tr>\n<th>Input<\/th>\n<th>Output<\/th>\n<\/tr>\n<tr>\n<td>758 843<\/td>\n<td>Maximum number is: 843<\/td>\n<\/tr>\n<tr>\n<td>459 238<\/td>\n<td>Maximum number is: 459<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>Solution<\/h1>\n<p>With if-statement<\/p>\n<pre class=\"lang:java decode:true\">import java.util.*;\r\n\r\nclass Main {\r\n    public static void main (String[] args) throws java.lang.Exception {\r\n        Scanner s = new Scanner(System.in);\r\n        int x = s.nextInt();\r\n        int y = s.nextInt();\r\n       \r\n        if (x &amp;lt; y) System.out.println(\"Minimum number is: \" + x);\r\n        else System.out.println(\"Minimum number is: \" + y);\r\n        s.close();\r\n    }\r\n}<\/pre>\n<h1>Code refactoring<\/h1>\n<p>Without if-statement<\/p>\n<pre class=\"lang:java decode:true   \">import java.util.*;\r\n\r\nclass Main {\r\n    public static void main (String[] args) throws java.lang.Exception {\r\n        Scanner s = new Scanner(System.in);\r\n        int x = s.nextInt();\r\n        int y = s.nextInt();\r\n        s.close();\r\n        System.out.println(\"Minimum number is: \" + (x &amp;lt; y? x : y));\r\n    }\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Task. Were given two real numbers [latex]x[\/latex] and [latex]y[\/latex]. Find [latex]\\min (x, y)[\/latex]. Tests Input Output 758 843 Maximum number is: 843 459 238 Maximum number is: 459 Solution With if-statement import java.util.*; class Main { public static void main (String[] args) throws java.lang.Exception { Scanner s = new Scanner(System.in); int x = s.nextInt(); int &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=73\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":126,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[19,20],"jetpack_featured_media_url":"https:\/\/java.mazurok.com\/wp-content\/uploads\/templ_1347515233_orig_2-kota.jpg","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/73"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":9,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":144,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions\/144"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/media\/126"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}