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
KiRa [710]
4 years ago
10

Write a program that reads in X whole numbers and outputs (1) the sum of all positive numbers, (2) the sum of all negative numbe

rs, and (3) the sum of all positive and negative numbers. The user can enter the X numbers in any different order every time, and can repeat the program if desired.
Computers and Technology
1 answer:
maxonik [38]4 years ago
5 0

Answer:

  1. run = 'y'
  2. sumPos = 0
  3. sumNeg = 0
  4. grandTotal = 0
  5. while run == 'y':
  6.    num = input("Enter a whole number: ")
  7.    while(num != 't'):
  8.        num = int(num)
  9.        if(num > 0):
  10.            sumPos += num  
  11.        else:
  12.            sumNeg += num  
  13.        
  14.        grandTotal += num
  15.        num = input("Enter a whole number: ")
  16.    
  17.    print("Sum of positive: " + str(sumPos))
  18.    print("Sum of negative: " + str(sumNeg))
  19.    print("Grand total: " + str(grandTotal))
  20.    sumPos = 0
  21.    sumNeg = 0
  22.    grandTotal = 0
  23.    run = input("Do you wish to continue (y/n): ")

Explanation:

Firstly, we get ready all the necessary variables (Line 1 -4) to track the running status, summation of positive, negative and grand total of all input numbers.

We create a while loop to keep our program running when run status is still equal to 'y' (Line 9).

Next we create if else statements to check if the number is positive or negative and add them to either sumPos or sumNeg (Line 11-14). The value of the grandTotal will be accumulated no matter the input number is positive or negative (Line 16). This process will repeat until user input "t".

Then we can display the sum of positive, negative and all numbers (Line 19-21) and reset the sumPos, sumNeg and grandTotal to 0 (Line 22-24).

At last we prompt user to input their choice is they wish to continue the program (Line 25).  

You might be interested in
Transmits data as pulses of light through tiny tubes of glass Uses standard telephone lines to create a high-speed connection Co
defon

Answer:

The answer is "True".

Explanation:

To transfer data, the fiber optic wire used a high-speed data transmission medium, which includes a small glass or plastic polymers, that carry the light beam to transmit data through swift light flashes through the cable.

  • It enables the transmission of data more quickly over larger distances.
  • In this cable, the traditional cable use to provide web data transfer to cable TV, that why the given statement is true.
4 0
3 years ago
Sarah has entered data about football players from team A and team B in a worksheet. She enters names of players from team A wit
deff fn [24]
I believe the answer is freeze pane view

7 0
4 years ago
Read 2 more answers
Explica la importancia que tiene el plan de trabajo (cronograma) en los proyectos y porque se realiza antes de ejecutar la soluc
zysi [14]

Answer:

El plan de trabajo permite delimitar la necesidad a la cual se debe responder con una solución (<em>descripción del problema</em>), los hitos que se deben alcanzar (<em>objetivos general y específico</em>), los recursos requeridos para lograr desarrollar y aplicar la solución (<em>marco teórico</em>), los posibles beneficios derivados del proceso exitoso (<em>justificación del proyecto</em>) y una administración racional y realistas de los recursos a disposición en cuanto a disponibilidad, tiempo y personal mediante una secuenciación de tareas (i.e. <em>diagramas de Gantt</em>), todo reduce el componente iterativo inherente a diseño y producción de un producto, permite prever posibles imprevistos y mantener una perspectiva realista y una eficiencia aceptable en cuanto a presupuesto, metodologías y tecnologías a usar.

El plan de trabajo debe incluir principios de ingeniería concurrente para minimizar para manera mejor los posibles imprevistos, usualmente difíciles de manera con principios de ingeniería secuencial.

Explanation:

El plan de trabajo permite delimitar la necesidad a la cual se debe responder con una solución (<em>descripción del problema</em>), los hitos que se deben alcanzar (<em>objetivos general y específico</em>), los recursos requeridos para lograr desarrollar y aplicar la solución (<em>marco teórico</em>), los posibles beneficios derivados del proceso exitoso (<em>justificación</em>) y una administración racional y realistas de los recursos a disposición en cuanto a disponibilidad, tiempo y personal mediante una secuenciación de tareas (i.e. diagramas de Gantt), todo reduce el componente iterativo inherente a diseño y producción de un producto, permite prever posibles imprevistos y mantener una perspectiva realista y una eficiencia aceptable en cuanto a presupuesto, metodologías y tecnologías a usar.

El plan de trabajo debe incluir principios de ingeniería concurrente para minimizar para manera mejor los posibles imprevistos, usualmente difíciles de manera con principios de ingeniería secuencial.

5 0
3 years ago
The science of networking is attributed to which government's involvement?
worty [1.4K]

Answer:

The United States

if I am not mistaken

6 0
3 years ago
What protocol is used to access directory listings within active directory or other directory services?
zalisa [80]

The LDAP protocol is used to access directory listings within active directory or other directory services.

LDAP stands for Lightweight Directory Access Protocol. The function of this protocol is to enale access to an existing direcory. LDAP is based on a client-server model.


3 0
4 years ago
Other questions:
  • The Internet and World Wide Web allow almost any business to be global. What are two important results of this process?
    8·1 answer
  • Print a countdown from n to 1 The function below takes one parameter: an integer (begin). Complete the function so that it print
    8·1 answer
  • How can you tell that you're driving in the right direction?
    14·1 answer
  • In which of the following situations should you expect to provide your Social Security number?
    13·1 answer
  • What do economists call a decline in the real GDP combined with a temporary rise in price level?
    8·2 answers
  • ____ includes any attempt to intentionally conduct dishonest activities online.
    5·1 answer
  • What is a benefit of starting a new business from scratch?
    8·1 answer
  • Most hand sewing begins and ends with
    5·1 answer
  • In the context of intentional computer and network threats a ____ is a programming routine built into a system by its designer
    14·2 answers
  • What privacy risks do new technologies present,<br> and how do we decide if they're worth it?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!