## Internet Question Interview Question

Country: United States
Interview Type: Written Test

Comment hidden because of low score. Click to expand.
0
of 0 vote

``````package com.Practice;

public class DiceGameCC {

static int sum(int arr[]){
int total =0;
int n = arr.length;
for(int i=0;i<n;i++){
total = total+arr[i];
}
}

public static int randomNum(int min, int max){

int randomNum = min + (int) (Math.random() * (max - min)+1);
//System.out.println("Num  "+randomNum);
return randomNum;
}

public static void main(String[] args) {
// TODO Auto-generated method stub

System.out.println("Player 1 turn : ");
int player1[] = new int[10];
for(int i=0;i<10;i++){
player1[i] = randomNum(0,6);
System.out.print(player1[i] +" ");
}
System.out.println(" ");

System.out.println("Player 2 turn : ");
int player2[] = new int[10];
for(int i=0;i<10;i++){
player2[i] = randomNum(0,6);
System.out.print(player2[i]+" ");
}
System.out.println(" ");

if(sum(player1) > sum(player2)){
System.out.println("Player 1 wins with score : "+(sum(player1)));
}
else
System.out.println("Player 2 wins with Score : "+sum(player2));
}

}``````

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Arrays;

public class diceExample {

/**
* @param args
*/
public static void main(String[] args) {
int [] player1 = new int[10];
int [] player2 = new int[10];
int player1Sum=0;
int player2Sum=0;
System.out.println("first will throw dice 10 time");

for(int i=0;i<9;i++){
int value=1+(int)(Math.random()*6);
player1[i]=value;
player1Sum=player1Sum+value;
}
System.out.println("first will throw dice 10 time");

for(int i=0;i<9;i++){
int value=1+(int)(Math.random()*6);
player2[i]=value;
player2Sum=player2Sum+value;
}
System.out.println("first Array");
for (int i = 0; i < player1.length; i++) {
System.out.println(player1[i]);
}
System.out.println("second Array");
for (int i = 0; i < player2.length; i++) {
System.out.println(player2[i]);
}
System.out.println(player1Sum);
System.out.println(player2Sum);
}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.Arrays;

public class diceExample {

/**
* @param args
*/
public static void main(String[] args) {
int [] player1 = new int[10];
int [] player2 = new int[10];
int player1Sum=0;
int player2Sum=0;
System.out.println("first will throw dice 10 time");

for(int i=0;i<9;i++){
int value=1+(int)(Math.random()*6);
player1[i]=value;
player1Sum=player1Sum+value;
}
System.out.println("first will throw dice 10 time");

for(int i=0;i<9;i++){
int value=1+(int)(Math.random()*6);
player2[i]=value;
player2Sum=player2Sum+value;
}
System.out.println("first Array");
for (int i = 0; i < player1.length; i++) {
System.out.println(player1[i]);
}
System.out.println("second Array");
for (int i = 0; i < player2.length; i++) {
System.out.println(player2[i]);
}
System.out.println(player1Sum);
System.out.println(player2Sum);
}

}

Comment hidden because of low score. Click to expand.
0
of 0 vote

Is this the first homework for Introduction to Programming course in high school?

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.