viewing paste Unknown #15687 | Java

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
package elo;
 
import java.util.Random;
 
import javax.swing.JOptionPane;
 
public class Main {
    public static void main(String [] args){
        double playerA = 1000;
        double playerB = 1000;
        while(Integer.parseInt(JOptionPane.showInputDialog("1 oder 0")) != 0){
            Random rm = new Random();
            int a = rm.nextInt(2);
            int b = 0;
            if(a == 0){
                System.out.println("Player B won!");
                b = 1;
            }else{
                System.out.println("Player A won!");
            }
            double Ea = 1/(1+Math.pow(10,((playerB - playerA)/400)));
            int Ra = (int) (playerA + 10*(a-Ea));
            int Rb = (int) (playerB + 10*(b-(1-Ea)));
            System.out.println("Player A: " + Ra);
            System.out.println("Player B: " + Rb);
            playerA = Ra;
            playerB = Rb;
        }
    }
}
 
Viewed 565 times, submitted by Guest.