Advertisement
Guest User

PrediccionJuego

a guest
Nov 22nd, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.04 KB | None | 0 0
  1. // ALejadro Lobo
  2. // Humberto Nieva
  3. // Implementacion de logica difusa para el pronostico de un juego
  4.  
  5. import java.util.Scanner;
  6. public class PrediccionJuego
  7. {
  8.     private static Scanner teclado;
  9.  
  10.     public static void main( final String[] args) {
  11.         int pe1, pe2,e=0,e1=0,i,gt,nr1=0,nr2=0;
  12.         float jg,x,l=0,w=0,d=0,y,jj;
  13.  
  14.         teclado = new Scanner(System.in);
  15.  
  16.         System.out.print( "Introduzca la posicion del equipo 1 : " );
  17.         pe1 = teclado.nextInt();
  18.  
  19.         System.out.print( "Introduzca la posicion del equipo 2 : " );
  20.         pe2 = teclado.nextInt();
  21.  
  22.         System.out.print( "Juegos jugados en el torneo: " );
  23.         jj = teclado.nextInt();
  24.  
  25.         for (i = 0; i < 2; i++) {
  26.             if (i==0) {
  27.                   System.out.print( "Juegos ganados del equipo en la posicion #"+pe1+": " );
  28.                   jg = teclado.nextInt();x=(jg/jj)*100; System.out.println("JG/JJ: "+x);
  29.  
  30.                   System.out.print( "Goles Totales hasta el momento del equipo en la posicion #"+pe1+": " );
  31.                   gt = teclado.nextInt();y=(gt/jj); System.out.println("Goles por partido: "+y);
  32.             }
  33.             else{
  34.                 System.out.print( "Juegos ganados del equipo en la posicion #"+pe2+": ");
  35.                   jg = teclado.nextInt();x=(jg/jj)*100; System.out.println("JG/JJ: "+x);
  36.  
  37.                   System.out.print( "Goles Totales hasta el momento del equipo en la posicion #"+pe1+": " );
  38.                   gt = teclado.nextInt();y=(gt/jj); System.out.println("Goles por partido: "+y);
  39.             }
  40.            
  41.             if (x<=50 && x>=25) {
  42.                 l=((50-x)/25);
  43.             } else if (x<25) {
  44.                 l=1;
  45.             }
  46.             if (x>=25 && x<=40) {
  47.                 d=((x-25)/15);
  48.             }
  49.             else  if (x>=40 && x<=60) {
  50.                 d=1;
  51.             }
  52.             else if (x>=60 && x<=75) {
  53.                 d=((75-x)/5);
  54.             }
  55.             if (x>=50 && x<=75) {
  56.                 w=((x-50)/25);  
  57.             }
  58.             else if (x>75) {
  59.                 w=1;
  60.             }
  61.             switch (i) {
  62.                 case 0:
  63.                    
  64.                     if(w>l){
  65.                         if(w>d){
  66.                            e=2;
  67.                         }
  68.                     } else{
  69.                              e=1;
  70.                         }
  71.                     if (l>w) {
  72.                         if (l>d) {
  73.                            e=0;
  74.                         }            
  75.                     }else{
  76.                            e=1;
  77.                     }
  78.                  
  79.                     break;
  80.                 case 1:
  81.                    
  82.                     if(w>l){
  83.                         if(w>d){
  84.                            e1=2;
  85.                         }
  86.                     } else{
  87.                              e1=1;
  88.                         }
  89.                     if (l>w) {
  90.                         if (l>d) {
  91.                             e1=0;
  92.                         }            
  93.                     }else{
  94.                             e1=1;
  95.                     }break;
  96.             }
  97.         }
  98.         if(e1>e || pe1<pe2){
  99.             System.out.println( "Equipo de la posicion #" + pe1 + " le gana el juego contra equipo de la posicion #" +pe2);
  100.             nr1 = (int)(Math.random()*4+0);
  101.             nr2 = (int)(Math.random()*(nr1-1)+0);
  102.             System.out.println("\n Con marcador: "+nr1+ " - "+nr2);
  103.         }else
  104.         if(e<e1 || pe1>pe2){
  105.             System.out.println( "Equipo de la posicion #" + pe1 + " pierde el juego contra equipo de la posicion #" +pe2);
  106.             nr2 = (int)(Math.random()*4+0);            
  107.             nr2 = (int)(Math.random()*(nr1-1)+0);
  108.             System.out.println("\n Con marcador: "+nr1+ " - "+nr2);
  109.         }
  110.         else{
  111.             int nrand = (int)(Math.random()*3+0);
  112.             System.out.println("El juego quedo empate");
  113.             System.out.println("\n Con marcador: "+nrand+ " - "+nrand);
  114.            
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement