Jogo de Dados em Java
import java.util.Scanner;
import java.util.InputMismatchException;
 
public class jogo_de_dados
{
    public static int joga(int a, int b) {
        int c = 0;        
        int i = 1;
        while(i<a+1){
            c = c + (1 + (int)(Math.random() * b)); 
            i = i + 1;
        }
        return c;        
    }
 
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("quantos dados?");
        int a = sc.nextInt();
        Scanner sc1 = new Scanner(System.in);
        System.out.println("quantas faces");
        int b = sc1.nextInt();
        System.out.println("-------->" + joga(a,b));
    }
 
}

voltar

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.