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
Give five functions of Windows​
Nata [24]

Answer:

Explanation:

It knows how to remember data and where to find that data. In other words, it knows how the raw memory works. (RAM).

It understands how to make a program run within the confines of its logical steps in an order that makes the program work the way the user intends.

It can be made to display short cuts, or any icon or picture (not an obvious talent).

It can search for unwanted intruders like ads or viruses.

It can can time events even to the point of getting your coffee ready for you with the proper add on.

6 0
3 years ago
Write the pseudocode for a program that will process attendance records of CA students. The students attend college five days a
Alenkasestr [34]

Using the knowledge of pseudocodes it will be possible to write a code that calculates the amount of hours worked and giving warnings about it.

<h3>Writing a pseudocode we have that:</h3>

<em>while </em>

<em>if number == 0</em>

<em>break</em>

<em>hours =0 </em>

<em>for i =1 to 5 </em>

<em>hours = hours + time_out[ i ] - time_in[ i ]</em>

<em> If hours >36 : </em>

<em>print ( "Name is " ,name)</em>

<em>print( "No of hours are ",hours)</em>

<em>print("Congratulaion! Your working hours are more than 36")</em>

<em>If hours <30 : #</em>

<em>print ( "Name is " ,name)</em>

<em>print( "No of hours are ",hours)</em>

<em>print("Warning !!!")</em>

<em>End loop</em>

See more about pseudocode at brainly.com/question/13208346

#SPJ1

3 0
2 years ago
Drag each tile to the correct box.
garri49 [273]
I think select the video insert select the movie option under illustrations resize the video player then select the insert tab i’m not 100 percent sure tho
8 0
3 years ago
Read 2 more answers
Aniyah is setting up a group of computers in her office that will share several devices. Which type of operating system should s
jenyasd209 [6]

Answer:

B

Explanation:

the software needs to share thus should be networked

8 0
2 years ago
how could environmental and energy problem Kenya faces as far computer installations are concerned be avoided​
ipn [44]

The environmental and energy problem Kenya faces as far computer installations are concerned can be avoided​ by

  • Knowing and finding out the key aspect of ICT strength.
  • Create an holistic judgements in the assessment of ICT capability. Promote the use of solar power.

<h3>How can we overcome ICT challenges?</h3>

There are a lot of Energy Challenges in terms of ICT  in Kenyan and it is good the government and the people work towards energy in terms of sustainable ICT.

Therefore, The environmental and energy problem Kenya faces as far computer installations are concerned can be avoided​ by

  • Knowing and finding out the key aspect of ICT strength.
  • Create an holistic judgements in the assessment of ICT capability. Promote the use of solar power.

Learn more about computer installations from

brainly.com/question/11430725

#SPJ1

7 0
2 years ago
Other questions:
  • 4. Discuss the advantages and disadvantages of using the same system call interface for both files and devices. Why do you think
    5·1 answer
  • Barr the Bear has started a business to sell fish to Poe and his fellow penguins. The penguin customers submit many fish orders,
    12·1 answer
  • When the tcp\ip translates a network layer address into a data link layer address (after not finding an entry for the network la
    13·1 answer
  • Word 2013 opens, by default, on a blank document?
    13·2 answers
  • File-sharing programs such as Napster, Kazaa, and iMesh make it possible for individuals to exchange music files over the Intern
    7·1 answer
  • Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opene
    8·1 answer
  • The concept of "space" on a computer usually refers to the___.​
    7·1 answer
  • What enables image processing, speech recognition, and complex game play in Artificial Intelligence (AI)?
    7·1 answer
  • 23. ____________ is a slide that is used as the base design theme for other slides.​
    11·1 answer
  • An employee of a large corporation remotely logs into the company using the appropriate username and password. The employee is a
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!