my vb.net program giving me 2 errors:
- it not break when enter negative value or 0.
- it not show me total values.
can me problem?
enter deposit amount: 300 (y or n)? y enter deposit amount: -1 amount cannot 0 or negative.
my code:
module module1 sub main() dim userresponse char dim depositamount decimal dim totaldeposits decimal dim depositcount integer dim averagedeposit decimal depositcount = 0 totaldeposits = 0 while not (userresponse = "n") console.writeline("enter desposit amount:") if (depositamount < 0 , depositamount = 0) console.writeline("amount cannot 0 or negative.") else depositamount = console.readline() console.writeline("another (y or n)?") userresponse = console.readline() totaldeposits = totaldeposits + depositamount depositcount = depositcount + 1 averagedeposit = totaldeposits / depositcount end if end while console.writeline(" total deposits: " + totaldeposits.tostring) console.writeline(" number of deposits: " + depositcount.tostring) console.writeline("average deposit: " + averagedeposit.tostring) end sub end module
you may able try: if (depositamount < 0 or depositamount = 0) see value cannot negative , 0 @ same time.
Comments
Post a Comment