The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2002



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


What to do:-)

Posted by senthoor on February 20, 2002 at 7:57 PM

right after your loop you can have a System.out.println() to achieve the purpose of showing the total number of items. Have a integer (int) variable called total out side the loop and initialise it to 0.

int total = 0;

Indise the loop after you get the response have an if statement and increase the total.

response = EasyIn.getChar(); //get response
if (response!='5')

Then outside the loop you could displace the total as the total number of items purchased.

If you would like the avoid the if condition which checks for '5' you may do so and outside the loop when displaying just reduce 1 from total and display...


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us