99 004
Assignments Done
99%
Successfully Done
In May 2021

# Answer to Question #48979 in Java | JSP | JSF for nada

Question #48979
hello
can you help me please !
Write a java program to execute the following operations:
1- Create two arrays as follows:
String season[]={&quot;Summer&quot;,&quot;Winter&quot;,&quot;Autumn&quot;,&quot;Spring&quot;}

Floattemp[]={26.8f,44.6f,12.9f,10.4f,50.1f,45.0f,33.7f,39.0f};

2- By using (for loop) and ( if statement) check each temperature in temp[] array as the following condition:

 If season=Summer and temp&gt;40 print the following message:
Ex: &quot; 45.0 is the temperature in summer season&quot;

 If season=Winter and temp&lt;20 print the following message:
Ex: &quot; 12.9 is the temperature in winter season&quot;

 If season=Autumn and temp&gt;20 and temp&lt;30 print the following message:
Ex: &quot; 26.8 is the temperature in Autumn season&quot;

 If season=Spring and temp&gt;30 and temp&lt;40 print the following message:
Ex: &quot; 33.7 is the temperature in spring season&quot;
1
Expert's answer
2014-11-18T14:30:45-0500
public class Main {
public static void main(String[] argv) {
String[] seasons = {"Summer", "Winter", "Autumn", "Spring"
};

float[] temps = {26.8f, 44.6f, 12.9f, 10.4f, 50.1f, 45.0f, 33.7f, 39.0f };
for (String season :seasons) {
for(float temp : temps) { //create a foreach cycle
if (season.equals("Summer") && temp >=
40) {
System.out.println(temp + " is the
temperature in summer season");
}
if (season.equals("Winter" && temp <
20) {
System.out.println(temp + " is the
temperature in winter season");
}
if (season.equals("Autumn" && temp >=
20 && temp < 30) {
System.out.println(temp + " is the
temperature in autumn season");
}
if (season.equals("Spring" && temp >=
30 && temp < 40) {
System.out.println(temp + "is the
temperature in spring season");
}
}
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

#### Comments

No comments. Be the first!

### Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS