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
Sptr is a pointer pointing to the beginning of an array called sarray. To access the value in sarray[3] by using the pointer, yo
kupik [55]

Answer:

The correct option for accessing the value in sarray[3] is : d) *(sptr+3)

Explanation:

a) *sptr[*3]  is wrong option because its syntax is not right it will give errors.

b) *sptr+3 is also wrong option because it will add 3 to the value of sarray[0].

c) sptr+3 is wrong option because it will only access the address of sarray[3] not the value it contains.

d) *(sptr +3) is correct syntax for accessing value in sarray[3] by using pointer

4 0
3 years ago
Which tag appears in the element of an HTML file? A. B. C. D. E.
vekshin1

element the answer is Explanation:

3 0
3 years ago
Read 2 more answers
Most common level of education for a programmer or software developer
shusha [124]

c/c+ also java would be one

8 0
3 years ago
1. Withdrawal occurs when alcohol is removed from the system after the brain has
Westkost [7]
Experienced it for an extended period of time.
4 0
3 years ago
Do all the OSs provide support for multiprocessing?
Zigmanuir [339]

Answer: No, not all the OSs provides facilitation working with multiprocessor.

Explanation: Multiprocessing is the executing different tasks at the same point of time within a system through two or more processors. Multiprocessing is not supported by the single processor operating system(OS) .

Single processor system cannot operate several tasks at the same time and cannot run the processes simultaneously.But, most of the modern operating system are designed in a way that it can support multiprocessing.

4 0
3 years ago
Other questions:
  • What is the difference between Data and information?​
    7·1 answer
  • Marie uses a browser to visit a blog. What is the unique identifier of the blog?
    13·2 answers
  • each term to the appropriate definition. DBMS data mining hash file index key field locking protocol relation roll back schema S
    14·1 answer
  • Image-editing software is used to _____.
    15·2 answers
  • Why would businesses apply cell protection to spreadsheet entries? Provide one specific example.
    10·1 answer
  • To give your app users the ability to open your app directly from other apps by clicking a link, you should use:.
    11·1 answer
  • domain controllers store local user accounts within a sam database and domain user accounts within active directory. true or fal
    10·1 answer
  • Write a method that takes a Rectangle as a parameter, and changes the width so it becomes a square (i.e. the width is set to the
    8·1 answer
  • 2) A ________ uses electronic memory and has no motors or moving parts. A) mechanical hard drive B) solid-state drive C) Blu-ray
    10·1 answer
  • Question 12
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!