Ask Question
21 October, 02:48

Alguém me ajuda nesse algoritmo?

usar visualg

ler 10 valores e escrever quantos desses valores lidos são negativos

+5
Answers (1)
  1. 21 October, 03:18
    0
    First we must import the package import java. util.*;

    we create our scanner and we declare our variables and array

    We create a for cycle, and inside the for the If sentence to evaluate every number then we print our negative and positive numbers.

    numbers[10]

    nega

    posi

    Scanner num = new Scanner (System. in);

    int numbers[] = new int[10];

    int nega = 0;

    int posi = 0;

    for (int i=0; i<=9; i++)

    {

    System. out. print ("Enter the number " + (i+1) + ":");

    numbers[i] = num. nextInt ();

    if (numbers[i]<0) {

    nega++;

    }

    else

    {

    posi++;

    }

    System. out. println ("Negative numbers are: " + nega);

    System. out. println ("Positive numbers are: " + posi);

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Alguém me ajuda nesse algoritmo? usar visualg ler 10 valores e escrever quantos desses valores lidos são negativos ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers