Advertisement
martinmircea

Mircea Java

Jul 4th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4. class Joc {
  5.     public static void main(String args[]){
  6.         int val1=0,val2=0;
  7.        
  8.         System.out.println("Numele jucatorului \t Numarul dat");
  9.         Scanner tura1 = new Scanner(System.in);
  10.         String first = tura1.next();
  11.         Random dice = new Random();
  12.         val1 = dice.nextInt(100);
  13.         System.out.println(tura1.nextLine() + "                         " + val1); 
  14.         System.out.println("Numele jucatorului \t Numarul dat");
  15.         Scanner tura2 = new Scanner(System.in);
  16.         String seconde = tura2.next();
  17.         val2 = dice.nextInt(100);
  18.         System.out.println(tura2.nextLine() + "                         " + val2); 
  19.        
  20.         if (val1 > val2){
  21.             System.out.println("Castigatorul este " + first);
  22.         }else if(val1 == val2){
  23.             System.out.println("Este egalitate");
  24.         }else{
  25.             System.out.println("Castigatorul este " + seconde);
  26.         }
  27.        
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement