Ask Question

Alguém me ajuda nesse algoritmo?

usar visualg

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

+4
Answers (1)
  1. 30 June, 16:49
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers