+ 2
Do...while loop help
Question is: User enter a positive number and syntax execute “Enter a number: “ User enter a negative number it stop and will say “STOP! You entered a negative number” It should also count the number of positive number entered It should also sum the number of positive number enter.
10 odpowiedzi
+ 18
@Limitless , i think u should take input in an array & then process ... it would not be possible here to give input 1 after amother after seeing the output
+ 16
@Limitless , in that case it will throw exception if u'll enter only non -ve numbers
+ 14
@Limitless
//try entering 1 2 , ... since 2>=0, the do while () loop'll run again & will not found any user input
//for n positive elements , loop will run n+1 times and there are only n numbers as input
+ 4
But yes, Ravi has a point. You should at least try the code first, and only when you fail it, you should ask the community. That way we can help you
+ 3
did you try to write the code and failed? if so please post the code, I will help you
+ 3
+ 3
different inputs should be given on different lines:
Input box:
5 {enter}
6 {enter}
7 {enter}
-8
Using an array in my opinion will take up more memory, unless the question specified that we should use an array.
+ 1
hmm I didn't get any Exceptions
+ 1
ohh, so you mean that when there's no further input the loop also stops.
ok edited code again
0
Here is my code.
https://code.sololearn.com/cqu3hHnV66x8/#java