{"id":2105,"date":"2023-06-20T08:13:00","date_gmt":"2023-06-20T08:13:00","guid":{"rendered":"https:\/\/myvlcsys.com\/?p=2105"},"modified":"2023-07-26T15:54:00","modified_gmt":"2023-07-26T15:54:00","slug":"java-indice-de-mas-corporal","status":"publish","type":"post","link":"https:\/\/myvlcsys.com\/?p=2105","title":{"rendered":"JAVA: \u00cdndice de masa corporal."},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p>Mostramos el c\u00f3digo JAVA que pide al usuario su altura y peso, y devuelve el resultado del \u00edndice de masa corporal (IMC). <\/p>\n\n\n\n<p>Para calcular el indice de masa corporal se usa la siguiente formula:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"331\" height=\"143\" src=\"https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/imagen.png\" alt=\"\" class=\"wp-image-2114\" srcset=\"https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/imagen.png 331w, https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/imagen-300x130.png 300w\" sizes=\"(max-width: 331px) 100vw, 331px\" \/><\/figure>\n<\/div>\n\n\n<p>Para la realizaci\u00f3n de este programa importaremos la librer\u00eda java.util. Tambi\u00e9n usaremos la clase Scanner para la lectura de datos mediante teclado. <\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package myvlcsys;\n\nimport java.util.Scanner;\n\npublic class calculoIMC {\n\n\tpublic static void main(String&#91;] args) {\n\t\t\/\/ TODO Auto-generated method stub\n\t\t \n\t\t\tScanner sc = new Scanner(System.in);\n\t        System.out.print(\"Introduce tu altura (ejm:1,70): \");\n\t        double altura = sc.nextDouble();\n\t        System.out.print(\"Introduce tu peso en kilogramos (ejm:70,5): \");\n\t        double peso = sc.nextDouble();\n\t        sc.close();\n\t \n\t        double imc = calcIMC(altura, peso);\n\t \n\t        String tipo = \"\";\n\t        if(imc &lt; 16){\n\t            tipo = \"Infrapeso: Delgadez severa\";\n\t        } else if(imc &lt; 17){\n\t            tipo = \"Infrapeso: Delgadez moderada\";\n\t        } else if(imc &lt; 18.50){\n\t            tipo = \"Infrapeso: Delgadez aceptable\";\n\t        } else if(imc &lt; 25){\n\t            tipo = \"Peso normal\";\n\t        } else if(imc &lt; 30){\n\t            tipo = \"Sobrepeso\";\n\t        } else if(imc &lt; 35){\n\t            tipo = \"Obeso: Tipo 1\";\n\t        } else if(imc &lt; 40){\n\t            tipo = \"Obeso: Tipo 2\";\n\t        } else {\n\t            tipo = \"Obeso: Tipo 3\";\n\t        }\n\t \n\t        System.out.println(\"\\nTu \u00edndice de masa corporal es: \" + imc);\n\t        System.out.println(\"Segun el IMC, tiene: \" + tipo);\n\t \n\t}\n\n\t\/\/Procedimiento para c\u00e1lculo matem\u00e1tico\n\n\tprivate static double calcIMC(double altura, double peso){\n       \n\t\tdouble miImc = peso\/(Math.pow(altura, 2));\n        return Math.rint(miImc*100)\/100;\n    }\n\n}\n<\/code><\/pre>\n\n\n\n<p>Como observamos el c\u00f3digo ademas de la clase principal(main), agregamos un <strong>procedimiento llamado calcIMC<\/strong>, al que le pasamos el valor de la variable de tipo double de la altura y al del peso, para realizar el calculo matem\u00e1tico.<\/p>\n\n\n\n<p>El resultado de nuestro programa ser\u00e1 el que mostramos a continuaci\u00f3n:<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"676\" src=\"https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/calculoIMC-1024x676.png\" alt=\"\" class=\"wp-image-2119\" srcset=\"https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/calculoIMC-1024x676.png 1024w, https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/calculoIMC-300x198.png 300w, https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/calculoIMC-768x507.png 768w, https:\/\/myvlcsys.com\/wp-content\/uploads\/2023\/06\/calculoIMC.png 1508w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Calculo IMC<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Mostramos el c\u00f3digo JAVA que pide al usuario su altura y peso, y devuelve el resultado del \u00edndice de masa corporal (IMC). Para calcular el indice de masa corporal se&hellip; <\/p>\n","protected":false},"author":4,"featured_media":2321,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[32,13],"tags":[35,25,47,36,24],"class_list":["post-2105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-progrmacion","tag-java","tag-linux","tag-myvlcsys","tag-programacion-2","tag-terminal"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/myvlcsys.com\/index.php?rest_route=\/wp\/v2\/posts\/2105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myvlcsys.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myvlcsys.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myvlcsys.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/myvlcsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2105"}],"version-history":[{"count":10,"href":"https:\/\/myvlcsys.com\/index.php?rest_route=\/wp\/v2\/posts\/2105\/revisions"}],"predecessor-version":[{"id":2213,"href":"https:\/\/myvlcsys.com\/index.php?rest_route=\/wp\/v2\/posts\/2105\/revisions\/2213"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/myvlcsys.com\/index.php?rest_route=\/wp\/v2\/media\/2321"}],"wp:attachment":[{"href":"https:\/\/myvlcsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myvlcsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myvlcsys.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}