Promedios en Java

También podría gustarte

Está en la página 1de 2

/*

* To change this template, choose Tools | Templates


* and open the template in the editor.
*/
package ciclo_;

import java.util.Scanner;
import javax.swing.*;
/**
*
* @author pc
*/
public class Ciclo_ {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Ciclo_ x1=new Ciclo_();
// TODO code application logic here
Scanner x=new Scanner(System.in);
float c=0,nota,pro=0,num,y;
int ex,base;
/*nota=-1;
//nota=x.nextFloat();
while(nota==-1 || nota<5){
do{System.out.println("Ingrese nota entre 0 y 100: "); nota=x.nextFloat();
}while(nota<100&&nota>0);
if(nota==-1){}else
c=c+nota;

}pro=c/5;
System.out.println("total: "+c);
System.out.println("Promedio: "+pro);

//calcula la sumatoria de una potencia


System.out.println("Ingrese el numero de veces: ");ex=x.nextInt();
//System.out.println("Ingrese el numero de exponente: ");ex=x.nextInt();
while(c<ex){
System.out.println("ingrese numero");num=x.nextFloat();
base=(int) Math.pow(num,ex);
pro=pro+base;
c++;
}
System.out.println("El resultado de la sumatoria de exponentes: "+pro);
*/
int cont=0;
int c_num;
long re=0;
//do{ }while(c_num<1);//System.out.println("Ingrese el numero de
exponente: ");ex=x.nextInt();
System.out.println("Ingrese el numero de veces: ");c_num=x.nextInt();

while(c<c_num){
cont++;
//System.out.println("ingrese numero");num=x.nextFloat();
//base=(int) Math.pow(num,ex);
re=re+(c_num/(c_num-cont));
c++;
}
System.out.println("El resultado de la sumatoria de exponentes: "+c);
JOptionPane.showInputDialog(null,"");

int a,b,c1=0,m=0,d=0;
System.out.println("ingrese primer numero: ");a=x.nextInt();
System.out.println("ingrese segundo numero: ");b=x.nextInt();
while(c<b){c++;
m=m+a;
//d=d-b;

}
c=0;
while(a>=b){
a-=b;
c++;
}
d=a;
System.out.println("la multiplicacion es: "+m);
System.out.println("la division es: "+c);
}
}

También podría gustarte