Vous êtes sur la page 1sur 4

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio_funciones;

/**
*
* @author PM
*/
public class Ejercicio_funciones {

public static void main(String[] args) {

int[] numeros={1,2,3,4,5,6,7,8,9};

mostrarArreglo(numeros);

System.out.println("la suma del vector es"+sumaArreglo(numeros));

static void mostrarArreglo(int[] numeros){

for(int i=0;i<numeros.length;i++){

System.out.print(numeros[i]);

static int sumaArreglo(int [] numeros){//necesito entregarle los numeros del


arreglo

int suma=0;
for(int i=0;i<numeros.length;i++){
suma+=numeros[i];
}
return suma;

}
}

-----------------------------------------------------------------------------------
------------------------------------
-----------------------------------------------------------------------------------
------------------------------------

package ejercicio1_funciones;

import java.util.Scanner;
public class Ejercicio1_funciones {

public static void main(String[] args) {

int N;

Scanner sc=new Scanner(System.in);

N=sc.nextInt();
mostrarMensaje(N);

static void mostrarMensaje(int n){

for(int i=0;i<n;i++){

System.out.print(" M�dulo ejecut�ndose \n ");

-----------------------------------------------------------------------------------
----------------------------------

-----------------------------------------------------------------------------------
----------------------------------

package ejercicio2_funciones;

import java.util.Scanner;

public class Ejercicio2_funciones {

public static void main(String[] args) {

Scanner lectura=new Scanner(System.in);

int x,y;

System.out.println("Ingrese dos numeros: ");

x=lectura.nextInt();
y=lectura.nextInt();
calMax(x,y);
}

static void calMax(int a, int b){//necesito entregarle los numeros del arreglo
int max=0;

if(a>b){

max=a;

}else{

max=b;
}

System.out.println("El maximo es: "+max);

-----------------------------------------------------------------------------------
----------------------------------
package ejercicio3_funciones;

import java.util.Scanner;

public class Ejercicio3_funciones {

public static void main(String[] args) {

int x,y,z;

x=leerNumero();
y=leerNumero();
z=leerNumero();

calMax(x,y,z);
}

static int leerNumero(){

Scanner lectura=new Scanner(System.in);

int numero;

System.out.println("Ingrese numero: ");

numero=lectura.nextInt();

return numero;

static void calMax(int a, int b, int c){//necesito entregarle los numeros del
arreglo
int max=0;

if(a>b && a>c){

max=a;

}else if(b>a &&b>c){

max=b;

}else{

max=c;
}

System.out.println("El maximo es: "+max);

Vous aimerez peut-être aussi