{"id":599,"date":"2024-01-09T19:11:57","date_gmt":"2024-01-09T19:11:57","guid":{"rendered":"https:\/\/javigomez.org\/?p=599"},"modified":"2025-09-29T20:33:44","modified_gmt":"2025-09-29T20:33:44","slug":"u06-06-funciones-para-mostrar-y-devolver-otro-array-con-los-elementos-multiplicados","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2024\/01\/09\/u06-06-funciones-para-mostrar-y-devolver-otro-array-con-los-elementos-multiplicados\/","title":{"rendered":"U06-06-Funciones para mostrar y devolver otro array con los elementos multiplicados"},"content":{"rendered":"\n<p>Pedir por pantalla cuantos n\u00fameros se van a escribir y pedirlos por pantalla almacen\u00e1ndolos en un array.<\/p>\n\n\n\n<p>Crear una funci\u00f3n mostrar que reciba el array y muestra los n\u00fameros por pantalla. static void mostrar(int t[]))<\/p>\n\n\n\n<p>Pedir\u00a0 otro n\u00famero por pantalla y crear una funci\u00f3n que multiplique cada uno de los n\u00fameros del array por el n\u00famero introducido. Esta funci\u00f3n debe devolver otro array diferente con los datos modificados. static int[] multiplicar(int t[],int x)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Java-U6-06-MutiplicadorArray\n\npackage U6;\n\nimport java.util.Arrays;\nimport java.util.Scanner;\n\npublic class A000 {\n\n\tpublic static void main(String&#91;] args) {\n\t\t\n\t\tScanner sc = new Scanner(System.in);\n\t\tSystem.out.println(\"Cuantos elementos tiene el array?: \");\n\t\tint numeroEle= sc.nextInt();\n\t\t\n\t\tint numeros&#91;] = new int&#91;numeroEle];\n\t\t\n\t\tfor (int i=0;i&lt;numeros.length;i++) {\n\t\t\tSystem.out.println(\"Introduce el elemento \" + (i+1));\n\t\t\tnumeros&#91;i]=sc.nextInt();\n\t\t}\n\t\t\n\t\tmostrar(numeros);\n\t\t\n\t\tSystem.out.println(\"Multiplicador: \");\n\t\tint mult= sc.nextInt();\n\t\t\n\t\tint m&#91;]=multiplicador(numeros,mult);\n\t\t\n\t\tmostrar(m);\n\t\t\n\t\t\n\t\t\n\t}\n\n\tprivate static int&#91;] multiplicador(int&#91;] numeros, int mult) {\n\t\tint m&#91;] = new int&#91;numeros.length];\n\t\tfor (int i=0;i&lt;numeros.length;i++)\n\t\t\tm&#91;i]=numeros&#91;i]*mult;\n\t\treturn m;\n\t}\n\n\tprivate static void mostrar(int&#91;] numeros) {\n\t\tfor (int i=0;i&lt;numeros.length;i++) {\n\t\t\tSystem.out.println(\"Elemento \" + (i+1) +\":\" + numeros&#91;i]);\n\t\t}\n\t\t\n\t}\n\t\t\n\n\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-4-3 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Java U6 06 MutiplicadorArray\" width=\"1200\" height=\"900\" src=\"https:\/\/www.youtube.com\/embed\/GkbZEnsGQ6w?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Pedir por pantalla cuantos n\u00fameros se van a escribir y pedirlos por pantalla almacen\u00e1ndolos en un array. Crear una funci\u00f3n mostrar que reciba el array &hellip; <\/p>\n","protected":false},"author":1,"featured_media":600,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[40,167,203,237,240],"class_list":["post-599","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-array","tag-funciones","tag-java","tag-mostrar","tag-multiplicar"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/comments?post=599"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/599\/revisions"}],"predecessor-version":[{"id":903,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/599\/revisions\/903"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media\/600"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}