Results 1 to 1 of 1
Thread: Counting with a sentinel loop
- 03-22-2011, 07:38 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 48
- Rep Power
- 0
Counting with a sentinel loop
To me, at first glance, the groupCount will go up until the sentinel is read in then reset for the next group of numbers. Instead, what it does is keeps counting, instead of finding that in the first group there are 4 numbers then in the second group finding that there are 6 numbers; it totals out to give me 10.Java Code:while(num > SENT) { if(PS) { System.out.println("This is the" + num); } groupCount++; groupSum = groupSum + num; if(PS) { System.out.println("This is the" + groupCount+ "and the" + groupSum); } num = scan.nextDouble(); }
I figured it out.
-bash-3.2$ facepalmLast edited by Teclis; 03-22-2011 at 07:40 PM.
Similar Threads
-
sentinel help
By droidus in forum New To JavaReplies: 12Last Post: 03-04-2011, 02:58 PM -
Counting Words
By Shyamz1 in forum New To JavaReplies: 9Last Post: 03-03-2011, 01:12 PM -
Help with Sentinel Loops
By hedwards09 in forum New To JavaReplies: 11Last Post: 11-07-2009, 07:39 PM -
Counting help
By jksmithson in forum New To JavaReplies: 1Last Post: 11-06-2009, 02:43 AM -
Counting with a delayed loop and using button to break
By danmc in forum New To JavaReplies: 1Last Post: 03-03-2009, 12:46 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks