- 1
Java array
Write a program to store the names of the months in an array and the number of days of each month in another array Then Printing the names of the months that have 30 days? Calculate the number of months that have 31 days? The solution is using the Java language
3 Answers
+ 1
Pls share your attempt ?
0
Please complete at least 50% of the Java course here in order to be able to solve the task. SoloLearn is a site to learn, code, seek genuine help and interact, so please don't expect free solutions to homeworks, assignments, etc. I hope that this helps.
0
Manualy create an arrays.
The first one (with names) will be String array and the second one int array.
Initialize int variable for sum with starting value 0.
Then use for loop to iterate through the int array.
Inside the loop put two if statements. First check if number of days is equal 30 then print name stored in string array with the same index of actual item in iteration.
And second if statement for checking if number of days is equal 31 and then add to sum plus one.
When loop ends just print sum value.