Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if(sum<total) {
int temp5=total-sum;
throw new InsufficientFund("Incomplete Transaction
Please pay remaining amount: " +temp5);

}
else if(sum==total) {
throw new TransactionComplete("Transaction Complete
Thank You for using Machine");
}
else if(sum>total) {
int temp5=total-sum;
throw new ExtraAmountPaid("Extra Amount Paid please
take remainging amount: " +temp5);
}

What I have tried:

Tried using this keywoods also loops but didn't find solution
Posted
Comments
GKP1992 4-May-18 2:11am    
Why did you decide to use exceptions to achieve this?
Richard MacCutchan 4-May-18 4:06am    
Whatever happens in the above code an exception will be thrown. Who catches it and what do they do?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900