Please help.
Statement needs to print:
"Please enter the insured value of your home as a whole number: "
Which is simple but if I enter a double the another statement prints that reads: "You must only enter an integer: "
That is where I'm stuck. Any way I do it I get fatal logic errors.
Here is my code starting with declared variable and skipping the in between code:
double homeInsVal = 0.0;
<other code>
System.out.printf("%nPlease enter the insured value of your home as a whole number: ");
homeInsVal = input.nextDouble();
{
if (homeInsVal >= 0.0)
{
System.out.printf("%nYou must only enter an integer: ");
homeInsVal = input.nextInt();
}
}
My logic is completely off. The reason why I declare homeInsVal as a double is because if I declare it as a Int as soon as I enter a decimal to purposely prompt the second statement I get a logic error an my code terminates but the way I currently have the code written the second prompt will print even if I enter an integer.
Please help!
Note: This is an intro Java class and while beggars can't be choosers have please explain as simple as possible. Thanks!