1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Naily [24]
3 years ago
8

Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a

nd computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number. Sample Run 1
Computers and Technology
1 answer:
nika2105 [10]3 years ago
3 0

Answer:

import java.util.Scanner;

public class NumbersStats {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int pos = 0, neg = 0, count = 0, num;

       double total = 0;

       System.out.print("Enter an integer, the input ends if it is 0: ");

       while (true) {

           num = in.nextInt();

           if(num == 0) break;

           if(num > 0) {

               pos++;

           } else {

               neg++;

           }

           total += num;

           count++;

       }

       System.out.println("The number of positives is " + pos);

       System.out.println("The number of negatives is " + neg);

       System.out.println("The total is " + total);

       System.out.println("The average is " + (total/count));

   }

}

Explanation:

You might be interested in
Greg works outside. He is often found cutting grass and making the local park grounds look nice for guests.
kvasek [131]

Answer:

C Landscaper

Explanation:

From what I know about landscapers and from the description that makes the most sense.

3 0
3 years ago
………………….. is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of
frutty [35]
Control <span>is the process of causing a system variable to conform to some desired value. Options Control feedback Design none of the above</span>
4 0
2 years ago
In this chapter, you saw an example of how to write an algorithm that determines whether a number is even or odd. Write a progra
vagabundo [1.1K]

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Program starts here

public class RandomOddEve {

/** Main Method */

public static void main(String[] args) {

int[] nums = new int[100]; // Declare an array of 100 integers

// Store the counts of 100 random numbers

for (int i = 1; i <= 100; i++) {

nums[(int)(Math.random() * 10)]++;

}

int odd = 0, even = 0; // declare even and odd variables to 0, respectively

// Both variables will serve a counters

// Check for odd and even numbers

for(int I = 0; I<100; I++)

{

if (nums[I]%2 == 0) {// Even number.

even++;

}

else // Odd number.

{

odd++;

}

}

//.Print Results

System.out.print("Odd number = "+odd);

System.out.print("Even number = "+even);

}

8 0
3 years ago
Read 2 more answers
Into which of these files would you paste copied information to create an integrated document? A. Mailing list B. Source C. Data
viva [34]

it would be b.mailing list


5 0
3 years ago
Read 2 more answers
What wired channel, commonly used for cable tv, consists of an insulated copper wire wrapped in a solid or braided shield placed
Airida [17]
the answer is A coaxial cable
8 0
2 years ago
Other questions:
  • Monica needs a printer to use at home. She wants fine-quality prints at an affordable cost. Which printer will help her achieve
    9·1 answer
  • Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
    14·1 answer
  • It is better to know the main components of all computer programming languages
    9·1 answer
  • How can the Column settings be accessed?
    12·2 answers
  • NEED THIS NOW PLEASE!!!! (I AM NOT JOKING I HAVE TO SUBMIT IN 5 MINUTES)
    13·2 answers
  • The three tasks within data harmonization, namely: data consolidation, data cleansing, and data formatting use techniques called
    8·1 answer
  • The communication channel used in IMC must rev: 12_06_2018_QC_ CDR-223 Multiple Choice match the traditional channel used in tha
    14·1 answer
  • What is malware? a type of virus that spreads through a network connection a type of virus that targets programs and files any p
    12·1 answer
  • 1.
    7·1 answer
  • 4. The volume of a sphere is (4.0/3.0)rr3 and the surface area is 4.0rr2, where r is the radius of
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!