Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ALejadro Lobo
- // Humberto Nieva
- // Implementacion de logica difusa para el pronostico de un juego
- import java.util.Scanner;
- public class PrediccionJuego
- {
- private static Scanner teclado;
- public static void main( final String[] args) {
- int pe1, pe2,e=0,e1=0,i,gt,nr1=0,nr2=0;
- float jg,x,l=0,w=0,d=0,y,jj;
- teclado = new Scanner(System.in);
- System.out.print( "Introduzca la posicion del equipo 1 : " );
- pe1 = teclado.nextInt();
- System.out.print( "Introduzca la posicion del equipo 2 : " );
- pe2 = teclado.nextInt();
- System.out.print( "Juegos jugados en el torneo: " );
- jj = teclado.nextInt();
- for (i = 0; i < 2; i++) {
- if (i==0) {
- System.out.print( "Juegos ganados del equipo en la posicion #"+pe1+": " );
- jg = teclado.nextInt();x=(jg/jj)*100; System.out.println("JG/JJ: "+x);
- System.out.print( "Goles Totales hasta el momento del equipo en la posicion #"+pe1+": " );
- gt = teclado.nextInt();y=(gt/jj); System.out.println("Goles por partido: "+y);
- }
- else{
- System.out.print( "Juegos ganados del equipo en la posicion #"+pe2+": ");
- jg = teclado.nextInt();x=(jg/jj)*100; System.out.println("JG/JJ: "+x);
- System.out.print( "Goles Totales hasta el momento del equipo en la posicion #"+pe1+": " );
- gt = teclado.nextInt();y=(gt/jj); System.out.println("Goles por partido: "+y);
- }
- if (x<=50 && x>=25) {
- l=((50-x)/25);
- } else if (x<25) {
- l=1;
- }
- if (x>=25 && x<=40) {
- d=((x-25)/15);
- }
- else if (x>=40 && x<=60) {
- d=1;
- }
- else if (x>=60 && x<=75) {
- d=((75-x)/5);
- }
- if (x>=50 && x<=75) {
- w=((x-50)/25);
- }
- else if (x>75) {
- w=1;
- }
- switch (i) {
- case 0:
- if(w>l){
- if(w>d){
- e=2;
- }
- } else{
- e=1;
- }
- if (l>w) {
- if (l>d) {
- e=0;
- }
- }else{
- e=1;
- }
- break;
- case 1:
- if(w>l){
- if(w>d){
- e1=2;
- }
- } else{
- e1=1;
- }
- if (l>w) {
- if (l>d) {
- e1=0;
- }
- }else{
- e1=1;
- }break;
- }
- }
- if(e1>e || pe1<pe2){
- System.out.println( "Equipo de la posicion #" + pe1 + " le gana el juego contra equipo de la posicion #" +pe2);
- nr1 = (int)(Math.random()*4+0);
- nr2 = (int)(Math.random()*(nr1-1)+0);
- System.out.println("\n Con marcador: "+nr1+ " - "+nr2);
- }else
- if(e<e1 || pe1>pe2){
- System.out.println( "Equipo de la posicion #" + pe1 + " pierde el juego contra equipo de la posicion #" +pe2);
- nr2 = (int)(Math.random()*4+0);
- nr2 = (int)(Math.random()*(nr1-1)+0);
- System.out.println("\n Con marcador: "+nr1+ " - "+nr2);
- }
- else{
- int nrand = (int)(Math.random()*3+0);
- System.out.println("El juego quedo empate");
- System.out.println("\n Con marcador: "+nrand+ " - "+nrand);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement