Question: What is the UML diagram for this program: MonthDaysTest.java import java.util.Scanner; public class MonthDaysTest { public static void main(String[] args) { Scanner scan = new

What is the UML diagram for this program:

MonthDaysTest.java

import java.util.Scanner;

public class MonthDaysTest {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter a month (1-12): ");

int month = scan.nextInt();

System.out.println("Enter a year: ");

int year = scan.nextInt();

MonthDays m = new MonthDays(month, year);

System.out.println(m.getNumberOfDays()+" days");

}

}

MonthDays.java

public class MonthDays {

private int month ;

private int year;

public MonthDays(int m, int y){

month = m;

year = y;

}

public int getNumberOfDays(){

int days = 0;

if(month ==1 || month == 3 || month ==5 || month == 7 || month ==8 || month == 10 || month == 12){

days = 31;

}

else if(month == 4 || month == 6 || month == 9 || month ==11){

days = 30;

}

else if(month == 2){

if ((year%4 == 0 && year%100 !=0)|| year%400 == 0)

days = 29;

else

days = 28;

}

return days;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!