I'm doing an exercise and I need help. Here is the statement:
Calculate the average temperatures of each month. To do this, create a list containing the names of each month in the rows, and the number of days of each month in the columns. On each day, store each temperature value written by the user. Then average the temperatures for each month.
Here is the code I've already done, but I do not even know how to do it right since I'm a beginner in Java:
import java.util.Scanner;
public class MediaTemperaturas {
public static void main (String args[]) {
double mês = new double[12][31];
for (int i = 0; i<11; i++);
Scanner sc = new Scanner (System.in);
String nomesMeses = sc.nextLine();
for (int j = 0; j<30;j++);
In order not to get too large, this test can be done with smaller numbers, for example 3 months, and each month contains 10 days (in which case you have to write 30 values (3 * 10) to reach the result of months). You can do:
double mes = new double [3][10];
**//Pra calcular a média, faz um:**
int soma = 0;
int media = 0;
if (int i = 0; i < dias.length; i++) {
soma += dias;
media = soma/dias.length;
return media;
}
My questions:
-
And how do you get the name of each month on the line?
-
How do you fill in the values in each column?
Can someone please help me with this Algorithm?
Ah, there's one more restriction: I can not use get
, set
, throw
, and this
, because what I'm doing is pretty basic and very beginner level. >