Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

java import java.util.Scanner; public class Hog { public static void main(String

ID: 3592362 • Letter: J

Question

java

import java.util.Scanner;
public class Hog
{
public static void main(String args[])
{
PairOfDice p1 = new PairOfDice();
PairOfDice p2 = new PairOfDice();
int grand_p1 = 0;
int grand_p2 = 0;
int count=0;

System.out.println( "You're rolling the dice . . .");
p1.roll();
grand_p1 += p1.getDiceSum();
System.out.println("This gives you a turn total of " + p1.getDiceSum());
System.out.println(" and a grand total of " + p1.getDiceSum());
System.out.println(" The computer has a total of " + grand_p2);
  
String msg = "Type 'y' when you're ready ";
System.out.println( msg);
Scanner sc = new Scanner(System.in);
String input = sc.nextLine();
  
while(input.equals("y"))
{
count++;
System.out.println( "You're rolling the dice . . .");
p1.roll();
grand_p1 += p1.getDiceSum();
System.out.println("This gives you a turn total of " + p1.getDiceSum());
System.out.println(" and a grand total of " + p1.getDiceSum());
System.out.println(" The computer has a total of " + grand_p2);

System.out.println( msg);
Scanner s = new Scanner(System.in);
String in = s.nextLine();
}
  
}
}

________________________________________________________________________________

outcome

________________________________________________________________________________

You're rolling the dice . . .
you rolled 6 5
This gives you a turn total of 11
and a grand total of 11
The computer has a total of 0
Type 'y' when you're ready
y
You're rolling the dice . . .
you rolled 3 3
This gives you a turn total of 6
and a grand total of 6
The computer has a total of 0
Type 'y' when you're ready

_______________________________________________________________________

how to accumulate the total for each round?

Explanation / Answer

EXPLANATION;

1.okay your code looks fine but you have missed the pairOfDice class so that i can check your implimentation.

2.still i can suggest you how to get computer total so that you can verify the implementation yourself.

3. for computer to get total in each round add this (below 2 lines only as third line is already in code) much code also for each iteration of loop. and for first basic prompt

p2.roll();

grand_p2 += p2.getDiceSum();

System.out.println(" The computer has a total of " + grand_p2);

//and for this below code line only you have to make correction to get total for each round ,for player (p1)

System.out.println(" and a grand total of " + p1.getDiceSum()); <------here in place of "p1.getDiceSum()" write "grand_p1" .

4.after making these correction your code will output correct.

// IF YOU HAVE ANY DOUBTS IN SOLUTION YOU MAY ASK AND PLEASE GIVE YOUR VALUABLE FEEDBACK
// IF YOU FEEL MY GUIDANCE TO BE HELPFUL DO PRESS THE THUMB UP BUTTON