Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate four times, once for each quarter. Each iteration of the inner loop will ask the user for the inches of rainfall for that quarter.

Answers

Answer 1

Answer & Explanation:

Written in java

import java.util.Scanner;

public class Main{

   public static void main(String[] args) {

       int totalRainfall = 0;

       int rainfall;

       Scanner keyboard = new Scanner(System.in);

       int year;

       do {

           System.out.println("Enter number of year(s): value must be greater than 0");

           year = keyboard.nextInt();

       } while (year < 1);

//        {

//

//            System.out.println("Invalid input, please enter a number greater than zero ");

//

//            year = keyboard.nextInt();

//

//        }

       for (int i = 0; i < year; i++) {

           for (int quarter = 1; quarter <= 4; quarter++) {

               int currentYear = 1 + i;

               System.out.println("Enter the inches of rainfall for year " + currentYear + " quarter " + quarter);

               rainfall = keyboard.nextInt();

               if(rainfall > -1){

                   totalRainfall += rainfall;

               }

               while (rainfall < 0) {

                   System.out.println("Enter the inches of rainfall for year " + currentYear + " quarter " + quarter +": value must be greater or equal to 0 ");

                   rainfall = keyboard.nextInt();

               }

           }

       }

       

       System.out.println("Average quarterly rainfall is: " + (totalRainfall/(year*4)));

       System.out.println("Average yearly rainfall is: " + (totalRainfall/(year)));

   }

}

Answer 2

Final answer:

A Python program is provided that calculates the average rainfall over a number of years. User inputs the number of years, then for each quarter of each year, the rainfall in inches. The program computes and outputs the average rainfall in inches and converts it to millimeters.

Explanation:

The program to calculate the average rainfall over a period of years will involve two nested loops. The outer loop will iterate through the number of years, while the inner loop will iterate through each quarter of a year. For each quarter, the program will collect the rainfall data in inches and calculate the average, eventually converting the final result to millimeters.

Python Code Example:

years = int(input('Enter number of years: '))
total_rainfall = 0
for year in range(1, years + 1):
 for quarter in range(1, 5):
   rainfall = float(input(f'Enter the inches of rainfall for year {year} quarter {quarter}: '))
   total_rainfall += rainfall
average_rainfall_inches = total_rainfall / (years * 4)
average_rainfall_mm = average_rainfall_inches * 25.4
print(f'The average rainfall over {years} years is {average_rainfall_inches} inches or {average_rainfall_mm} mm.')


Related Questions

Write an abstract superclass encapsulating a college applicant:

A college applicant has two attributes: the applicant’s name and the college the applicant is applying to.

This class has two non-abstract subclasses: one encapsulating an applicant for undergraduate school, and the other encapsulating an applicant for graduate school.

An applicant for undergraduate school has two attributes: a SAT score and a GPA. An applicant for graduate school has one additional attribute: the college of origin.

It also has a method that returns "from inside" if the college of origin is the same as the college applied to; otherwise, it returns "from outside".

You also need to include a class to test two classes.Java please.

Answers

Answer:

The code snippet file is attached. There are four files:

Abstract Applicant ClassThe Graduate ClassThe Undergraduate classThe TestApplicantClass

The code is well commented and explanatory.

Explanation:

Which of the following is the definition of registration authority ( RA)?

a. The process of applying an algorithm to cleartext (or plain text) data, resulting in a ciphertext.
b. The certificate authority’s list of invalid certificates.
c. The concept of ensuring that an originator cannot refute the validity of a statement or document.
d. An entity that is responsible for the registration and initial authentication of certificate subscribers.

Answers

Answer:

The correct answer following question will be Option D.

Explanation:

An authority that verifies the user requests for digital certificates and tells to the CA (Certificate authority) to issue the certificates, known as Registration Authority (RA). The digital certificate contains a key named "public key" which is used to encrypt and decrypt digital signatures.

Hence, registration authority, it's an entity that is responsible for the authentication of certificate and registration and the other given options are not relatable to this authority.

So, option D is the correct answer.

#include ... void sig_handler(){ static int i = 1; printf("Beep\n"); alarm(i); ++i; } int main(){ struct sigaction sa; sa.sa_flags = 0; sa.sa_handler = sig_handler; if(sigaction(SIGALRM, &sa, NULL) != 0){ printf("Failed to bind handler.\n"); exit(1); } printf("Going into an infinite loop.\n"); alarm(1); while(1); return 0; }

Suppose the above program is run for 7.5 seconds after it prints "Going into an infinite loop". The program is run multiple times where the "system load" from other processes sharing the cpu will vary from none to many other processes. Which best characterizes how many times "Beep" is printed?

Answers

Answer:

Explained below

Explanation:

After the compiling the program it prints "Going to infinite loop" after that i started the timer till 4.5 sec. The program prints more than 4 beeps nearly 6-7 beep messages were printed.

The number "Beep" would always be strictly greater than 4.

Hence, if the above program is run for 7.5 seconds after it prints "Going in an infinite loop", it will print Beep for about 9-10 times. Hence, the number will always be greater than 7

What should you double check for some reason its not working? You have created a workflow rule to send an email in your configuration sandbox.

A. You have the correct email address
B. HTML does not work in sandbox, make sure your email has no HTML
C. Check the deliverability settings
D. Look at the system audit trail

Answers

Answer:

Option A and C are the correct options

Explanation:

The following options is true because when the user created the flow of the work rule for sending an email in their configuration sandbox then, the user correct these email address and also users can examine their deliverability setting.

Option B is false because the HTML also works in the sandbox.

Option D is false because the audit trail did not look at the system.

Other Questions
In January 2001, the euro/dollar exchange rate was 1.10, and in January 2002, the euro/dollar exchange rate was 1.120. What happend to the exchange rate during this period?A. Euro depreciated against the dollarB. Euro appreciated against the dollarC. Dollar appreciated against the euroD. Both B and C What is the acceleration of this object? The object's mass is 2 kg. 11 m/s2 4 m/s2 0 m/s2 7 m/s2 Which event (s) corresponded with a rapid increase in the population growth rate of Las Vegas, NV If m1 + m2 = 137, what is m3? A skater has rotational inertia 4.2 kg.m2 with his fists held to his chest and 5.7 kg.m2 with his arms outstretched. The skater is spinning at 3.0 rev/s while holding a 2.5-kg weight in each outstretched hand; the weights are 76 cm from his rotation axis. If he pulls his hands in to his chest, so theyre essentially on his ro- tation axis, how fast will he be spinning? what are the masses (in kilograms) of the three objects in the Gizmo? potential shelves gizmo answer (Beowulf) what is a scop? The practice that assumes that nonwhite Americans are more likely to commit crimes than white Americans is called_______. The first three steps of completing the square to solve the quadratic equation x + 4x - 6 = 0, areshown below.Step 1: x2 + 4x = 6Step 2: x2 + 4x + 4 = 6 + 4Step 3: (x + 2)2 = 10What are the next 3 steps? Europes population fell by 30-60 percent following an outbrake of the bubonic plague, also known as the black death in the fourteenth century asw a result, europes production possibilities curve would__________. How many justices must agree to hear a case in order for it to be granted a writ of certiorari? In 2009 to 2010, 1 in 10 social network users:A. overshared personal information.B. used stricter security settings.OC. dealt with online abuse.D. stole someone's identity. The following question is based on your reading of the short stories of Flannery OConnor.What does the bus represent?a.Integrationc.Social classesb.Slaveryd.Racial segregation I WILL GIVE BRAINLIEST!!!! PLZ HELP!!!! ASAP!!!!m - 7 < 6A. m < -1B. m ? 1C. m < 13D. < - 13 The sum of the circumference of two circles is 38 cm and the sum of their areas is 193 cm. Calculate the radii of the circles. What is 68 in simplest radical form? help with question 7 part i & ii Summarize what causes foliated metamorphic textures to form. During the current year, the Guileman Manufacturing Company signed a noncancelable contract to purchase 1,000 lbs. of a raw material at $32 per lb. during the forthcoming year. On December 31, the market price of the raw material is $26 per lb., and the selling price of the finished product is expected to decline accordingly. The financial statements prepared for the year should report...A. An appropriation of retained earnings for $6,000.B. A loss of $6,000 in the income statement.C. Nothing regarding this matter.D. A note describing the expected loss on the purchase commitment. Select the correct answer.Jane has enrolled in the Air Force Officer Training School. How long will the program take?AFive-and-a-half weeks.Three weeks.B..Nine-and-a-half weeks.D.Two months. Steam Workshop Downloader