public class calendar{
public static void main(String[] args){
String months[]={"January","February","March","April","May",
"June","July","August","September","October",
"November","December"};
int DaysinMonth[]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
}
for(int i=0;i< months.length;i++){
System.out.println(months[i]);
for(int i=0;i< DaysinMonth.length;i++){
System.out.print(DaysinMonth[i]);
}
}
}
Hey I need help with the loops, im kind of new with this and im trying to figure how to do this. Can anyone help, I know since im making arrays that I need to have for loops but i dont know how to do it. Here are the directions.
Design a program that displays the number of days in each month. The program’s output should be similar to this:
January has 31 days.
February has 28 days.
March has 31 days.
April has 30 days.
May has 31 days.
June has 30 days.
July has 31 days.
August has 31 days.
September has 30 days.
October has 31 days.
November has 31 days.
December has 31 days.
The program should have two parallel arrays: a 12-element String array that is initialized with the names of the month, and a 12-element Integer array that is initialized with the number of days in each month. To produce the output specified, use a loop to step through the arrays getting the name of a month and the number of days in that month.

New Topic/Question
Reply




MultiQuote





|