Ojala Me puedan Ayudar!
Publicado: 29 Abr 2013, 01:52
Escribir un programa que calcule la media de x cantidad números introducidos por el teclado.
Saludos e gracias
Saludos e gracias
Indetectables es una Comunidad de Hacking, Seguridad Informática, Impresión 3d y Desarrollo
./index.php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package practicando1;
/**
*
* @author MARTIN
*/
import java.io.*;
public class Media {
public static void main(String[] args) throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
float acu=0;
float num,media;
System.out.print("Ingrese La cantidad de Numeros a los que le desea sacar la media: ");
media = Integer.parseInt(br.readLine());
for(int x=0;x<media;x++)
{
System.out.print("Ingres El Numero " + x+1 + " de " + media);
num=Integer.parseInt(br.readLine());
acu+=num;
}
System.out.println("La media de los " + media + " numeros es: " + acu/media);
}
}
Donde esta el error, a ver si me ayudan ...package practicando1;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package practicando1;
/**
*
* @autor xodcker
*/
import java.io.*;
public class Media {
public static void main(String[] args) throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
float acu=0;
int k=0;
int num,media;
System.out.print("Ingrese La cantidad de Numeros a los que le desea sacar la media: ");
media = Integer.parseInt(br.readLine());
for(int x=0;x<media;x++)
{
k=x+1;
System.out.print("Ingres El Numero " + k+ " de " + media);
num=Integer.parseInt(br.readLine());
acu+=num;
}
System.out.println("La media de los " + media + " numeros es: " + acu/media);
}
}