Dice Game Write a program that plays a simple dice game between the computer and the user. When the program runs, a loop should repeat 10 times. Each iteration of the loop should do the following: Generate a random integer in the range of 1 through 6. This is the value of the computer's die. . Generate another random integer in the range of 1 through 6. This is the value of the user's die. The die with the highest value wins. (In case of a tie, there is no winner for that particular roll of the dice.) As the loop iterates, the program should keep count of the number of times the computer wins, and the number of times that the user wins. After the loop performs all of its iterations, the program should display who was the grand winner, the computer or the user. Computername is a specially-formed String that consists of 3 letters (can be upper-case or lower-case), followed by a dash, followed by 4 numbers. For example, "abc-1234". All computer name follow this pattern, otherwise they are invalid. Use this UML diagram.

class: die
Data Memebers:
-computername: String
-Username: String
-sides: int
-value: int

Method Members:
+Die(sides : int)
+Die(computename:String,username:String)

+ getSide() :int

+ setSide(sides : int) : void

+ getValue() : int

+ setValue(value : int) : void

+roll() : void
+getComputername(): String
+setComputername(value: String):void
+getUsername(): String
+setUsername(value:String): void

Sample output:

Enter computer name: yza-3512
Enter user name: Johny
This simulates the rolling of a 6 sided die and a 6 sided die
Rolling the dice 10 times
Die1 Die2
3 6
5 4
6 6
6 5
1 4
4 4
6 6
1 2
3 5
2 6
Computer=8 user=2
Grand winner is computer yza-3512

Or

Grand winner is user xyz

Or

There is tie between computer xyz-1234 and user Han

public class Die {

private final int MAX_ROLLS = 10;
private int MAX = 6;
private int Sides;
private int value;

public Die() {
getSides();
setSides(6);
getValue();
setValue(6);
roll();
}

public int getSides() {
return Sides;
}
public void setSides(int sides) {
Sides = sides;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public void roll() {
System.out.println("Dice 1 Dice 2");
for (int i = 1; i <= MAX_ROLLS; i++) {
int q, p;
q = (int) (MAX * Math.random() + 1);
p = (int) (MAX * Math.random() + 1);
System.out.println(" " + q + " " + p);
}
}
public String getComputername(){
return "";
}
public void setComputername(String value){

}
public String getUsername(){
return "";
}
public void setUsername(String value){

}
}

public class TestDie {
public static void main(String[] args) {
int Sides, values;
Scanner input = new Scanner(System.in);

System.out.println("Enter Computer Name: ");
String comname = input.nextLine();

System.out.println("Enter User Name: ");
String Username = input.nextLine();

System.out.println("This Simulates the rolling of 6 sided die and" +
" a 6 sided die\nRolling the Dice 10 Times");
Die die1 =new Die();
Die die2 = new Die();
}
}

Can someone check my code why it keeps doing this all the time:

Computer....0
User........0
Ties........1
The game has ended in a tie!

In your code, you are missing the logic to keep track of the number of wins for the computer and the user. Additionally, you are not checking for the winner at the end of each roll.

To fix this issue, you can modify your code as follows:

1. Add two integer variables `computerWins` and `userWins` to keep track of the number of wins for the computer and the user.
2. Inside the loop in the `roll()` method, compare the values of `q` and `p` to determine the winner of each roll. Increment the corresponding win counter (`computerWins` or `userWins`) accordingly.
3. After the loop in the `roll()` method, compare `computerWins` and `userWins` to determine the grand winner of the game.
4. Display the final results at the end of the `TestDie` class.

Here's the modified code:

```java
public class Die {
// ... existing code ...

public Die() {
// ... existing code ...
}

// ... existing code ...

public void roll() {
int computerWins = 0;
int userWins = 0;
int ties = 0;

System.out.println("Dice 1 Dice 2");
for (int i = 1; i <= MAX_ROLLS; i++) {
int q, p;
q = (int) (MAX * Math.random() + 1);
p = (int) (MAX * Math.random() + 1);

// Compare q and p to determine the winner of each roll
if (q > p) {
computerWins++;
} else if (q < p) {
userWins++;
} else {
ties++;
}

System.out.println(" " + q + " " + p);
}

// Determine the grand winner of the game
if (computerWins > userWins) {
System.out.println("Grand winner is computer " + getComputername());
} else if (computerWins < userWins) {
System.out.println("Grand winner is user " + getUsername());
} else {
System.out.println("The game has ended in a tie!");
}
}

// ... existing code ...
}

public class TestDie {
public static void main(String[] args) {
// ... existing code ...

Die die1 = new Die();
Die die2 = new Die();

die1.roll();
}
}
```

With these modifications, the program should correctly keep track of the wins for the computer and the user, and display the final results accordingly.

There seems to be an issue with your code where you are not updating the score count correctly. You need to compare the values of the dice rolled in each iteration and update the score count accordingly. Here's an updated version of your code:

```java
import java.util.Scanner;

public class Die {
private final int MAX_ROLLS = 10;
private final int MAX = 6;
private int sides;
private int value;

public Die(String computername, String username) {
this.sides = 6;
this.value = 6;
}

public int getSides() {
return sides;
}

public void setSides(int sides) {
this.sides = sides;
}

public int getValue() {
return value;
}

public void setValue(int value) {
this.value = value;
}

public int roll() {
int computerScore = 0;
int userScore = 0;
int tieCount = 0;

for (int i = 0; i < MAX_ROLLS; i++) {
int computerDie = (int) (Math.random() * MAX) + 1;
int userDie = (int) (Math.random() * MAX) + 1;

System.out.println("Die1: " + computerDie + " | Die2: " + userDie);

if (computerDie > userDie) {
computerScore++;
} else if (userDie > computerDie) {
userScore++;
} else {
tieCount++;
}
}

System.out.println("Computer = " + computerScore + " | User = " + userScore + " | Ties = " + tieCount);

if (computerScore > userScore) {
return 1; // Computer wins
} else if (userScore > computerScore) {
return 2; // User wins
} else {
return 0; // Tie
}
}

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.println("Enter Computer Name: ");
String computerName = input.nextLine();

System.out.println("Enter User Name: ");
String userName = input.nextLine();

System.out.println("This Simulates the rolling of a 6 sided die and a 6 sided die");
System.out.println("Rolling the Dice 10 times");

Die game = new Die(computerName, userName);
int winner = game.roll();

if (winner == 1) {
System.out.println("Grand winner is computer " + computerName);
} else if (winner == 2) {
System.out.println("Grand winner is user " + userName);
} else {
System.out.println("The game has ended in a tie between computer " + computerName + " and user " + userName);
}
}
}
```

This updated code should correctly count the scores and determine the winner based on the number of wins for the computer and the user.