OK so what I want to do is create an infinite loop scanner that will add up all the values from the previously entered values which will then produce after each entered number the total value. How do I do this?
TIM_M_91
-3
Junior Poster in Training
Recommended Answers
Jump to Postwhile (true)
there is your infinite loop, but trust me, an infinite loop is the last thing you want in running code.
Jump to PostThe following piece of code will result in a compile-time error:
BigInteger c = a.nextBigInteger(); sum += c;
If the intent is to add BigIntegers then
sum
should be a BigInteger too.Here's a fix:
BigInteger sum = BigInteger.ZERO; // ... sum …
All 5 Replies
stultuske
1,116
Posting Maven
Featured Poster
TIM_M_91
-3
Junior Poster in Training
IIM
163
Master Poster
mvmalderen
2,072
Postaholic
IIM
163
Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.