Computer Science homework help?

Hello! this is my first semester studying computer science and I'm finding it quite difficult as it's entirely online but my professors give such small lectures. Right now I'm taking an algorithm class and I just want to make sure I have something correct if anyone can help!

the prompt is to Design a program that reads a collection of positive and negative numbers and multiplies only the positive integers. Loop exit should occur when three consecutive negative values are read. "I put my input as "input number double"so when I start my while loop, can it just say "while number > 0" for the positive integers or does the "> 0" imply that decimals bigger than 0 but less than 1 can be entered? Thanks in advance! (Also please don't give me the answer to the whole problem, I just want that simple question answered)

Relevance
• 2 weeks ago

ou can do something like

countx =0

multiplex=0

while(countx<3){

get input

If (input<0) {

countx++ }

else {

countx=0;

multiplex*=input;

}

}

• Tasm
Lv 6
3 weeks ago

You can do something like

countx =0

multiplex=0

while(countx<3){

get input

If (input<0) {

countx++ }

else {

countx=0;

multiplex*=input;

}

}

• 4 weeks ago

while (number >= 0)

However this only accounts for one positive numbercounter = 0;do{  read number;  if (number < 0) counter = counter + 1;  else counter = 0;}while (counter < 3)

• 4 weeks ago

The expression "number > 0" will be true whenever number is positive.  If that variable can hold a fraction, then fractions greater than 0 by any amount will compare as greater than 0.

That's true no matter where the comparison is done, in a while statement, if or elsif statement, or in anywhere else a boolean expression is allowed.