Write pseudocode in Java. The researchers will give you a log that contains several years of data representing the rainfall each month. You will be designing a program that will ask for the number of years to be processed. You will enter the rainfall for each month in the first year. After the first year has been processed, you will need to display the following information for the year: average rainfall for the year, the number of months with rainfall greater than 10 inches, and the number of months with rainfall less that 3 inches. All rainfall will be entered as whole inches.

Once the first year is complete, the program will loop for each year requested (use nested loops for the years and the months in the year).

When all the data has been entered, you will need to display the total number of inches for the whole period, the average rainfall per month over the whole period, the total number of months with rainfall greater than 10 inches, and the total number of months with rainfall less than 3 inches.

To accomplish this task, you will need to use nested loops. The outer loop will execute once for each year that needs to be entered. The inner loop will execute 12 times, once for each month in the year. The pseudocode should include the use of loops, decision structures, input and output, and calculations.

Respuesta :

Answer:

Explanation:

Sure! Here's an example of pseudocode in Java that accomplishes the task described:

```

// Declare variables

int totalYears, totalMonths;

int totalInches = 0;

int totalMonthsGreaterThan10 = 0;

int totalMonthsLessThan3 = 0;

// Get the number of years to be processed from the user

System.out.println("Enter the number of years to be processed:");

totalYears = readIntegerInput();

// Outer loop for each year

for (int year = 1; year <= totalYears; year++) {

int totalRainfall = 0;

int monthsGreaterThan10 = 0;

int monthsLessThan3 = 0;

// Inner loop for each month in the year

for (int month = 1; month <= 12; month++) {

System.out.println("Enter the rainfall for month " + month + " in year " + year + ":");

int rainfall = readIntegerInput();

totalRainfall += rainfall;

if (rainfall > 10) {

monthsGreaterThan10++;

} else if (rainfall < 3) {

monthsLessThan3++;

}

}

totalInches += totalRainfall;

totalMonthsGreaterThan10 += monthsGreaterThan10;

totalMonthsLessThan3 += monthsLessThan3;

// Display information for the year

System.out.println("Year " + year + " results:");

System.out.println("Average rainfall for the year: " + (totalRainfall / 12));

System.out.println("Number of months with rainfall greater than 10 inches: " + monthsGreaterThan10);

System.out.println("Number of months with rainfall less than 3 inches: " + monthsLessThan3);

}

// Calculate average rainfall per month over the whole period

float averageRainfallPerMonth = (float) totalInches / (totalYears * 12);

// Display overall results

System.out.println("Total number of inches for the whole period: " + totalInches);

System.out.println("Average rainfall per month over the whole period: " + averageRainfallPerMonth);

System.out.println("Total number of months with rainfall greater than 10 inches: " + totalMonthsGreaterThan10);

System.out.println("Total number of months with rainfall less than 3 inches: " + totalMonthsLessThan3);

```

In this pseudocode, we use nested loops to iterate through each year and each month in the year. The rainfall for each month is inputted by the user, and we keep track of various totals and counts. At the end, we calculate the average rainfall per month over the whole period and display the final results. Note that `readIntegerInput()` is a placeholder for a function or method that would read an integer input from the user.