public class MowTheLawnExample
{
public static void main(String args[])
{
// MowTheLawnExample
// Define variables. Perhaps define one more to help
String days[] =
{"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
String today; // The day of the week. e.g. "Monday"
int timeHour; // The hour of the time in 24 hour format.
// Place your code here. Hint: nested for loops.
for (int i=0; i= 10;
boolean beforeFour = timeHour < 16;
if ((isSaturday || isSunday) && (afterTen && beforeFour))
System.out.println("Mow the lawn.");
else
System.out.println("Do not mow the lawn!");
}
}
}
}
today is Sunday, time is 0:00. Do not mow the lawn! today is Sunday, time is 1:00. Do not mow the lawn! today is Sunday, time is 2:00. Do not mow the lawn! today is Sunday, time is 3:00. Do not mow the lawn! today is Sunday, time is 4:00. Do not mow the lawn! today is Sunday, time is 5:00. Do not mow the lawn! today is Sunday, time is 6:00. Do not mow the lawn! today is Sunday, time is 7:00. Do not mow the lawn! today is Sunday, time is 8:00. Do not mow the lawn! today is Sunday, time is 9:00. Do not mow the lawn! today is Sunday, time is 10:00. Mow the lawn. today is Sunday, time is 11:00. Mow the lawn. today is Sunday, time is 12:00. Mow the lawn. today is Sunday, time is 13:00. Mow the lawn. today is Sunday, time is 14:00. Mow the lawn. today is Sunday, time is 15:00. Mow the lawn. today is Sunday, time is 16:00. Do not mow the lawn! today is Sunday, time is 17:00. Do not mow the lawn! today is Sunday, time is 18:00. Do not mow the lawn! today is Sunday, time is 19:00. Do not mow the lawn! today is Sunday, time is 20:00. Do not mow the lawn! today is Sunday, time is 21:00. Do not mow the lawn! today is Sunday, time is 22:00. Do not mow the lawn! today is Sunday, time is 23:00. Do not mow the lawn! today is Monday, time is 0:00. Do not mow the lawn! today is Monday, time is 1:00. Do not mow the lawn! today is Monday, time is 2:00. Do not mow the lawn! today is Monday, time is 3:00. Do not mow the lawn! today is Monday, time is 4:00. Do not mow the lawn! today is Monday, time is 5:00. Do not mow the lawn! today is Monday, time is 6:00. Do not mow the lawn! today is Monday, time is 7:00. Do not mow the lawn! today is Monday, time is 8:00. Do not mow the lawn! today is Monday, time is 9:00. Do not mow the lawn! today is Monday, time is 10:00. Do not mow the lawn! today is Monday, time is 11:00. Do not mow the lawn! today is Monday, time is 12:00. Do not mow the lawn! today is Monday, time is 13:00. Do not mow the lawn! today is Monday, time is 14:00. Do not mow the lawn! today is Monday, time is 15:00. Do not mow the lawn! today is Monday, time is 16:00. Do not mow the lawn! today is Monday, time is 17:00. Do not mow the lawn! today is Monday, time is 18:00. Do not mow the lawn! today is Monday, time is 19:00. Do not mow the lawn! today is Monday, time is 20:00. Do not mow the lawn! today is Monday, time is 21:00. Do not mow the lawn! today is Monday, time is 22:00. Do not mow the lawn! today is Monday, time is 23:00. Do not mow the lawn! today is Tuesday, time is 0:00. Do not mow the lawn! today is Tuesday, time is 1:00. Do not mow the lawn! today is Tuesday, time is 2:00. Do not mow the lawn! today is Tuesday, time is 3:00. Do not mow the lawn! today is Tuesday, time is 4:00. Do not mow the lawn! today is Tuesday, time is 5:00. Do not mow the lawn! today is Tuesday, time is 6:00. Do not mow the lawn! today is Tuesday, time is 7:00. Do not mow the lawn! today is Tuesday, time is 8:00. Do not mow the lawn! today is Tuesday, time is 9:00. Do not mow the lawn! today is Tuesday, time is 10:00. Do not mow the lawn! today is Tuesday, time is 11:00. Do not mow the lawn! today is Tuesday, time is 12:00. Do not mow the lawn! today is Tuesday, time is 13:00. Do not mow the lawn! today is Tuesday, time is 14:00. Do not mow the lawn! today is Tuesday, time is 15:00. Do not mow the lawn! today is Tuesday, time is 16:00. Do not mow the lawn! today is Tuesday, time is 17:00. Do not mow the lawn! today is Tuesday, time is 18:00. Do not mow the lawn! today is Tuesday, time is 19:00. Do not mow the lawn! today is Tuesday, time is 20:00. Do not mow the lawn! today is Tuesday, time is 21:00. Do not mow the lawn! today is Tuesday, time is 22:00. Do not mow the lawn! today is Tuesday, time is 23:00. Do not mow the lawn! today is Wednesday, time is 0:00. Do not mow the lawn! today is Wednesday, time is 1:00. Do not mow the lawn! today is Wednesday, time is 2:00. Do not mow the lawn! today is Wednesday, time is 3:00. Do not mow the lawn! today is Wednesday, time is 4:00. Do not mow the lawn! today is Wednesday, time is 5:00. Do not mow the lawn! today is Wednesday, time is 6:00. Do not mow the lawn! today is Wednesday, time is 7:00. Do not mow the lawn! today is Wednesday, time is 8:00. Do not mow the lawn! today is Wednesday, time is 9:00. Do not mow the lawn! today is Wednesday, time is 10:00. Do not mow the lawn! today is Wednesday, time is 11:00. Do not mow the lawn! today is Wednesday, time is 12:00. Do not mow the lawn! today is Wednesday, time is 13:00. Do not mow the lawn! today is Wednesday, time is 14:00. Do not mow the lawn! today is Wednesday, time is 15:00. Do not mow the lawn! today is Wednesday, time is 16:00. Do not mow the lawn! today is Wednesday, time is 17:00. Do not mow the lawn! today is Wednesday, time is 18:00. Do not mow the lawn! today is Wednesday, time is 19:00. Do not mow the lawn! today is Wednesday, time is 20:00. Do not mow the lawn! today is Wednesday, time is 21:00. Do not mow the lawn! today is Wednesday, time is 22:00. Do not mow the lawn! today is Wednesday, time is 23:00. Do not mow the lawn! today is Thursday, time is 0:00. Do not mow the lawn! today is Thursday, time is 1:00. Do not mow the lawn! today is Thursday, time is 2:00. Do not mow the lawn! today is Thursday, time is 3:00. Do not mow the lawn! today is Thursday, time is 4:00. Do not mow the lawn! today is Thursday, time is 5:00. Do not mow the lawn! today is Thursday, time is 6:00. Do not mow the lawn! today is Thursday, time is 7:00. Do not mow the lawn! today is Thursday, time is 8:00. Do not mow the lawn! today is Thursday, time is 9:00. Do not mow the lawn! today is Thursday, time is 10:00. Do not mow the lawn! today is Thursday, time is 11:00. Do not mow the lawn! today is Thursday, time is 12:00. Do not mow the lawn! today is Thursday, time is 13:00. Do not mow the lawn! today is Thursday, time is 14:00. Do not mow the lawn! today is Thursday, time is 15:00. Do not mow the lawn! today is Thursday, time is 16:00. Do not mow the lawn! today is Thursday, time is 17:00. Do not mow the lawn! today is Thursday, time is 18:00. Do not mow the lawn! today is Thursday, time is 19:00. Do not mow the lawn! today is Thursday, time is 20:00. Do not mow the lawn! today is Thursday, time is 21:00. Do not mow the lawn! today is Thursday, time is 22:00. Do not mow the lawn! today is Thursday, time is 23:00. Do not mow the lawn! today is Friday, time is 0:00. Do not mow the lawn! today is Friday, time is 1:00. Do not mow the lawn! today is Friday, time is 2:00. Do not mow the lawn! today is Friday, time is 3:00. Do not mow the lawn! today is Friday, time is 4:00. Do not mow the lawn! today is Friday, time is 5:00. Do not mow the lawn! today is Friday, time is 6:00. Do not mow the lawn! today is Friday, time is 7:00. Do not mow the lawn! today is Friday, time is 8:00. Do not mow the lawn! today is Friday, time is 9:00. Do not mow the lawn! today is Friday, time is 10:00. Do not mow the lawn! today is Friday, time is 11:00. Do not mow the lawn! today is Friday, time is 12:00. Do not mow the lawn! today is Friday, time is 13:00. Do not mow the lawn! today is Friday, time is 14:00. Do not mow the lawn! today is Friday, time is 15:00. Do not mow the lawn! today is Friday, time is 16:00. Do not mow the lawn! today is Friday, time is 17:00. Do not mow the lawn! today is Friday, time is 18:00. Do not mow the lawn! today is Friday, time is 19:00. Do not mow the lawn! today is Friday, time is 20:00. Do not mow the lawn! today is Friday, time is 21:00. Do not mow the lawn! today is Friday, time is 22:00. Do not mow the lawn! today is Friday, time is 23:00. Do not mow the lawn! today is Saturday, time is 0:00. Do not mow the lawn! today is Saturday, time is 1:00. Do not mow the lawn! today is Saturday, time is 2:00. Do not mow the lawn! today is Saturday, time is 3:00. Do not mow the lawn! today is Saturday, time is 4:00. Do not mow the lawn! today is Saturday, time is 5:00. Do not mow the lawn! today is Saturday, time is 6:00. Do not mow the lawn! today is Saturday, time is 7:00. Do not mow the lawn! today is Saturday, time is 8:00. Do not mow the lawn! today is Saturday, time is 9:00. Do not mow the lawn! today is Saturday, time is 10:00. Mow the lawn. today is Saturday, time is 11:00. Mow the lawn. today is Saturday, time is 12:00. Mow the lawn. today is Saturday, time is 13:00. Mow the lawn. today is Saturday, time is 14:00. Mow the lawn. today is Saturday, time is 15:00. Mow the lawn. today is Saturday, time is 16:00. Do not mow the lawn! today is Saturday, time is 17:00. Do not mow the lawn! today is Saturday, time is 18:00. Do not mow the lawn! today is Saturday, time is 19:00. Do not mow the lawn! today is Saturday, time is 20:00. Do not mow the lawn! today is Saturday, time is 21:00. Do not mow the lawn! today is Saturday, time is 22:00. Do not mow the lawn! today is Saturday, time is 23:00. Do not mow the lawn!
--- Output Ends ---
- javac MowTheLawnExample.java
- java MowTheLawnExample