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
The ____________ is the part of the microprocessor that performs arithmetic operations, such as addition and subtraction.
navik [9.2K]

Answer:

ALU

Explanation:

Arithmetic Logic Unit (ALU) is the part of the microprocessor that performs arithmetic operations, such as addition, subtraction, AND, OR, NOT, XOR etc. ALU is also used for comparison of input numbers.

<u>HOW IT WORKS:</u>

When the code is compiled, the code is converted first to assembly language and then assembly language is converted to machine code.

In Machine language, each arithmetic or logic operation has a specific code known as OPCODE. This opcode tells ALU which operation to perform on the inputs.

6 0
4 years ago
Mateo wants the words “It’s snowing!” to appear in the interpreter and typed print (It's snowing). This didn’t work. What needs
natima [27]

Answer:

print("It's snowing")

Explanation:

since it a string you need put quotation marks the code does not understand just (It's snowing) because it thinks it variable which it is not

6 0
3 years ago
Your boss wants you to configure his laptop so that he can access the company network when he is on the road. You suggest a VPN
Rashid [163]

Answer:

All traffic that flows between the laptop and VPN server is encrypted.

Explanation:

A Virtual Private Network (VPN) is a "tunnel" connection between computers that performs just like a regular point-to-point network connection (that is, IP address to IP address).  It has the added feature that encryption is enabled so that no intermediate server (or computer or line monitor, etc.) can decode the information that is in the data portion of the packets.

5 0
3 years ago
Which of the following represents a bit?<br><br> 0<br><br> 01010110<br><br> 3F02C<br><br> 12.356
Olenka [21]

Answer:

0

Explanation:

A bit is a single piece of information and the smallest unit that can possibly represented by a computer, like 1 or 0.

7 0
3 years ago
______ is a certification program that recognizes sustainable building practices and strategies. Question 1 options: A) Brundtla
Pani-rosa [81]

Answer:

(C) LEED

Explanation:

LEED certification is a recognized worldwide as symbol of viability achievement.

(Leadership in Energy and Environmental Design(LEED):- It is the most popular and widely used rating system in the world for green buildings. Available for almost all building project types, including new constructions to interior fit-outs.

8 0
4 years ago
Other questions:
  • The original U.S. income tax of 1913 was quite simple. The tax was
    10·1 answer
  • Can any existing directory beneath the system root directory be used as a mount point?
    9·1 answer
  • Which of the following locations would most likely have the most fertile soil?
    8·1 answer
  • Please help me ! All you do is just put it it all in your own words ! Please this is for my reported card!i don't know how to pu
    15·1 answer
  • A device that converts analog signals into digital and vice versa for a computer to communicate over phone lines is called a ___
    8·1 answer
  • What is the term for a server at the highest level of the Domain Name System (DNS)?
    15·1 answer
  • State 3 file formats explain them in an understanding manner apart from Microsoft word and PDF
    5·1 answer
  • Match each item with a statement below. a.Authentication b.Brute force attack c.Dictionary attack d.Password e.Shoulder surfing
    13·1 answer
  • What’s the screen that displays results from typing text, performing calculations or running programs?
    9·1 answer
  • _________ Code that you write is called primary code, and code that the compiler produces after processing the primary code is c
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!