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
Tom [10]
3 years ago
10

(Count positive and negative numbers and compute the average of numbers) Write a program that reads an unspecified number of int

egers, determines how many positive and negative values have been read, and 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. Python
Computers and Technology
1 answer:
Papessa [141]3 years ago
7 0

Answer:

Explanation:

Sorry it  is in Java, though you can covert it using converter

public class Exercise {

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 int positives = 0;  // Count the number of positive numbers

 int negatives = 0;  // Count the number of negative numbers

 int count = 0;   // Count all numbers

 double total = 0;  // Accumulate a totol

 // Promopt the user to enter an integer or 0 to exit

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

 int number = input.nextInt();

 if (number == 0) { // Test for sentinel value

  System.out.println("No numbers are entered except 0");

  System.exit(1);

 }

 while (number != 0) {// Test for sentinel value

  if (number > 0)

   positives++; // Increase positives

  else

   negatives++; // Increase negatives

  total += number; // Accumulate total

  count++;    // Increase the count

  number = input.nextInt();

 }

 // Calculate the average

 double average = total / count;

 // Display results

 System.out.println(

  "The number of positive is " + positives +

  "\nThe number of negatives is " + negatives +

  "\nThe total is total " + total +

  "\nThe average is " + average);

}

}

You might be interested in
What is word processing program,Give 3 types of word processing program​
Lostsunrise [7]

Answer:

<h3><u>what is word processing program</u></h3>

<em>A word processor is a device or computer program that provides for input, editing, formatting, and output of text, often with some additional features. Early word processors were stand-alone devices dedicated to the function, but current word processors are word processor programs running on general purpose computers</em>

<h3><u>Give 3 types of word processing program</u></h3>

<u>Word processors are of 3 types which are electronic, mechanical, and software.</u>

...

<u>Examples or Applications of a Word Processing</u> <u>Software :</u>

  • Wordpad.
  • Microsoft Word.
  • Lotus word pro.
  • Notepad.
  • WordPerfect (Windows only),
  • AppleWorks (Mac only),
  • Work pages.
  • OpenOffice Writer.
8 0
2 years ago
Select the correct answer.
Kobotan [32]
I think that it's OD
7 0
3 years ago
________ errors may indicate that an attacker is trying to send invalid data to the server. 404 303 500 512
Lemur [1.5K]
<span>500 errors may indicate that an attacker is trying to send invalid data to the server. </span>
5 0
4 years ago
Which of the following statements is true of algorithms?
Agata [3.3K]

Answer:

Algorithms allow automation of complex task

Explanation:

I just did it

3 0
3 years ago
Which of these is a sign of healthy A)very high inflation B)A rise in consumers spending C)a shift supply of essential goods D)H
klemol [59]

im sorry i meant C 100%

6 0
3 years ago
Read 2 more answers
Other questions:
  • What key combination in excel takes you back to the first cell
    7·1 answer
  • When you compile your program, the compiler identifies the logic errors and suggests how to correct them?
    14·1 answer
  • Look at the following list of peripheral items and determine what type they are: mouse, keyboard, webcam, microphone. Input Outp
    15·1 answer
  • The Maui coffee shop sells coffee at $10.50 a pound plus the cost of shipping. Each order ships for $0.86 per pound + $1.50 fixe
    14·1 answer
  • In CadStd, what does the Zoom All button do? A. Makes a drawing bigger so you can see small details B. Returns a drawing to a si
    5·1 answer
  • Which is true about POP3 and IMAP for incoming email?
    10·1 answer
  • Are high tech messages are always preferable to low tech messages
    8·1 answer
  • Why is flash memory considered nonvolatile?
    5·1 answer
  • 1) List two hardware methods that can be used to secure data
    11·1 answer
  • What is a common misconception about Agile and DevOps?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!