# Dont know whats wrong?

import java.util.Scanner;
class Main
{ public static void main(String[] args)
{ System.out.println("How much dirt is there in a hole 3 ft deep, 6 ft long and 4 ft wide? ");
Scanner input = new Scanner(System.in);
String ans;
ans = "None";
do{ int question,
question = input.nextInt();
{ System.out.println("Correct! or else it wouldn't be hole.");
break; }
else { System.out.println("Wrong, try again."); } }
while (ans.equals("None"));
}

}

answered Nov 7, 2020 by (7,630 points)

int question,

# Corrected code:

question = input.nextInt ();

if (question == 3*6*4)  { ... }

# Updated code below:

```  import java.util.Scanner;
class Main
{
public static void main (String[]args)
{
System.out.println
("How much dirt is there in a hole 3 ft deep, 6 ft long and 4 ft wide? ");
Scanner input = new Scanner (System.in);
String ans;
ans = "None";
do
{
question = input.nextInt ();
if (question == 3*6*4)
{
System.out.println ("Correct! or else it wouldn't be hole.");
break;
}
else
{
System.out.println ("Wrong, try again.");
}
}
while (ans.equals ("None"));
}

}

```
commented Nov 8, 2020 by (140 points)
at java.base/java.util.Scanner.throwFor(Scanner.java:939)
at java.base/java.util.Scanner.next(Scanner.java:1594)
at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
at Main.main(try.java:14)

I still get an error code when entering the correct answer.
commented Nov 8, 2020 by (7,630 points)
Below is a sample run ,where I enter integers only.

How much dirt is there in a hole 3 ft deep, 6 ft long and 4 ft wide?
5
Wrong, try again.
72
Correct! or else it wouldn't be hole.

...Program finished with exit code 0
Press ENTER to exit console.

------------------------------------------------------------------------
If normal ints are given ithe input the prog works fine ,for string the code throws exceptions.Using try-catch blocks should take care of that.

But I am not sure if the above working is what u expected.
Perhaps share a few sample cases with  input & the expected output.