rastman222
Programmer
Writing some code for a check out procedure.
When the user inputs '0', I want the code to null the zero and go back to the last balance. Hitting 0 means mistake and whatever total entered be removed from the running total.
if(itemPrice >= 0.01 & itemPrice <= 4999.99)
{
count ++;
runningTotal += itemPrice;
System.out.println("Your total is $" + runningTotal);
}//end if
else if(itemPrice == 0)
{
itemPrice = null;*error*
count --;
runningTotal -= itemPrice;
System.out.println("Removing $" + itemPrice + " from your total. Your total is $" + runningTotal);
There error I'm getting is that it says it cannot convert from null to double. I've never really used null this way before so any insight would be appreciated.
If there is another way to do it...don't be afraid to let me know. I've googled and can't come up with a way to do it.
TIA
When the user inputs '0', I want the code to null the zero and go back to the last balance. Hitting 0 means mistake and whatever total entered be removed from the running total.
if(itemPrice >= 0.01 & itemPrice <= 4999.99)
{
count ++;
runningTotal += itemPrice;
System.out.println("Your total is $" + runningTotal);
}//end if
else if(itemPrice == 0)
{
itemPrice = null;*error*
count --;
runningTotal -= itemPrice;
System.out.println("Removing $" + itemPrice + " from your total. Your total is $" + runningTotal);
There error I'm getting is that it says it cannot convert from null to double. I've never really used null this way before so any insight would be appreciated.
If there is another way to do it...don't be afraid to let me know. I've googled and can't come up with a way to do it.
TIA