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
AlekseyPX
3 years ago
6

Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program sh

ould first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month.
After all iterations, the program chould display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. (We are using class' with this challenge)
Input validation: Do not acept less than 1 for the number of years. Do not accept negative numbers for the monthly rainfall.
Output:
Enter the number of years: -2
Invalid. Enter 1 or greater: 2
Enter the rainfall, in inches, for each month.
Year 1 month 1: -3
Invalid. Enter 0 or greater: 3
Year 1 month 2: 5
Year 1 month 3: 7
Year 1 month 4: 9
Year 1 month 5: 6
Year1 month 6: 0
Year 1 month 7: 0
Year 1 month 8: 0
Year 1 month 9: 3
Year 1 month 10: 6
Year 1 month 11: 10
Year 1 month 12 8
Year 2 month 1: 7
Year 2 month 2: 6
Year 2 month 3: 10
Year 2 month 4: 8
Year 2 month 5: 4
Year 2 month 6: 0
Year 2 month 7: 0
Year 2 month 8: 0
Year 2 month 9: 4
Year 2 month 10: 15
Year 2 month 11: 12
Year 2 month 12: 5
Number of months: 24
Total rainfall: 128.0 inches
Average monthly rainfall: 5.333333333333333 inches (there are 15 3's)
Computers and Technology
1 answer:
babunello [35]3 years ago
7 0

Answer:

In Python:

year = int(input("Years: "))

while year<1:

   year = int(input("Invalid. Enter 1 or greater: "))

total = 0

for i in range(1,year+1):

   for j in range(1,13):

       month = int(input("Year "+str(i)+", Month "+str(j)+": "))

       while month<0:

           month = int(input("Invalid. Enter 0 or greater: "))

       total+=month

ave = total/(12*year)

print("Months: "+str(12 * year))

print("Total: "+str(total))

print("Average: "+str(ave))

Explanation:

This gets the number of years

year = int(input("Years: "))

This loop validates the number of years

<em>while year<1:</em>

<em>    year = int(input("Invalid. Enter 1 or greater: "))</em>

<em />

This initializes total to 0

total = 0

This iterates through the years

for i in range(1,year+1):

This iterates through the month of each year

   for j in range(1,13):

This gets the rainfall for each month

       month = int(input("Year "+str(i)+", Month "+str(j)+": "))

This loop validates the amount of rainfall

<em>        while month<0:</em>

<em>            month = int(input("Invalid. Enter 0 or greater: "))</em>

This calculates the total rainfall

       total+=month

This calculates the average rainfall

ave = total/(12*year)

This prints the number of month

print("Months: "+str(12 * year))

This prints the calculated total amount of rainfall

print("Total: "+str(total))

This prints the calculated average amount of rainfall

print("Average: "+str(ave))

You might be interested in
A student dissolves some solid sodium hydroxide in a beaker of water.
STALIN [3.7K]
C water is the soulute
7 0
3 years ago
Read 2 more answers
Early photographers take to work with what in order to produce photographs? (Btw this is photography, it just isn't a subject in
Kruka [31]
1, they used to use chemicals.
4 0
3 years ago
Kevin is working on a financial project that involves a lot of statistical information. He needs software that allows him to ent
makvit [3.9K]

Answer: Spreadsheet Software

If Kevin would use a spreadsheet software, he will be able to input all of the statistical data and have the software generate graphs of the data that he has inputted into the spreadsheet. Using a spreadsheet software, Kevin will also have access to changing the graphs data whenever an anomaly has been detected.

Some of examples of these software would be:

  • Microsoft Excel
  • Open Office
  • Google Sheets
  • LibreOffice

8 0
3 years ago
Suppose that you are given the following partial data segment, which starts at address 0x0700 : .data idArray DWORD 1800, 1719,
Digiron [165]

Answer:

The value EAX contain after the code has been executed is 1233

Explanation:

Solution

Now,

The below instruction describes the MOV operation.

The MOV esi, OFFSET idArray .

It shows the movement, the offset value of the idArray in the esi.

Thus,

Follow the below instruction

MOV eax, [esi+7*TYPE idArray]

It will move the address of the idArray at that position into eax.

Value at the 7th position is moved to eax.

Therefore, the value at eax will be 1233.

5 0
4 years ago
While (e &lt; 10):<br> print (c)
Ymorist [56]

Answer:

Huh? can you ask a real question so I can answer?

Explanation:

7 0
3 years ago
Other questions:
  • During the Requirements Definition stage of a systems development​ project, the employees who will be the primary users of the n
    15·1 answer
  • In a cellular network, where does each wireless base station connect to?
    9·1 answer
  • To increase the view of a document on the screen, use the _____. View icon Zoom slider full-screen reading boldface font
    9·1 answer
  • Marco is ready to create his first slide. He wants to put the title of the
    11·1 answer
  • An IT systems engineer creates a new Domain Name System (DNS) zone that contains pointer (PTR) resource records. Which zone type
    15·1 answer
  • HELP ASAP. Which of the following is the best example of an installation issue? A computer can’t find the file that it needs to
    7·1 answer
  • The television is the biggest technological advancement in communication since the telephone.
    6·2 answers
  • Which approach to bandwidth usage consumes all of the available frequencies on a medium to transmit data
    7·1 answer
  • Where do you find the instructions, learning objectives, evaluation and scoring for this aba assignment?.
    15·1 answer
  • What is the current situation of drone technology in emergency rescue and recovery
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!