116k views
4 votes
Design an application in which the number of days for each month in the year is stored in an array. (For example, January has 31 days, February has 28, and so on. Assume that the year is not a leap year.) Display 12 sentences in the same format for each month; for example, the sentence displayed for January is Month 1 has 31 days.

2 Answers

0 votes

Final answer:

To design an application in which the number of days for each month in the year is stored in an array, create an array of integers representing the number of days in each month. Use a loop to display 12 sentences, each containing the month number and the corresponding number of days.

Step-by-step explanation:

To design an application in which the number of days for each month in the year is stored in an array, you can create an array of integers representing the number of days in each month. Here's an example:

int[] daysInMonth = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

Then, you can use a loop to display 12 sentences, each containing the month number and the corresponding number of days. Here's an example:

for (int i = 0; i < 12; i++) {
System.out.println("Month " + (i + 1) + " has " + daysInMonth[i] + " days.");
}

User Andyras
by
3.5k points
3 votes

Answer:

Check the explanation

Step-by-step explanation:

Pseudocode:

start

Declarations

num month

num SIZE = 12

num DAYS[SIZE] = 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31

displayDays()

finishUp()

stop

displayDays()

month = 0

while month < SIZE

output “Month ”, month+1, “ has ”, DAYS[month], “ days”

month = month + 1

endwhile

return

finishUp()

output “End of program”

return

================================================================

User Mreferre
by
3.3k points