Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; public class DaysInMonth{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(Enter month from 1-12: ); int month= sc.nextInt(); System.out.println(Enter

import java.util.Scanner; public class DaysInMonth{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter month from 1-12: "); int month= sc.nextInt(); System.out.println("Enter year: "); int year = sc.nextInt(); int m=sc.nextInt(); System.out.println(month + "/" + year + " has " + m + " days"); switch (m) { case 1: m = 31; break; case 2: if (isLeap(year)) m = 29; else m= 28; break; case 3: m = 31; break; case 4: m = 30; break; case 5: m = 31; break; case 6: m= 30; break; case 7: m = 31; break; case 8: m = 31; break; case 9: m= 30; break; case 10: m = 31; break; case 11: m = 30; break; case 12: m = 31; break; } } private static boolean isLeap(int year) { boolean leap = false; if (year % 4 == 0) { if (year % 100 == 0) { if (year % 400 == 0) leap = true; else leap = false; } else leap = true; } else leap = false; return leap; } }

Why I only can print the enter years and month but is not print the System.out.println(month + "/" + year + " has " + m + " days"); which is not print the result

javac DaysInMonth.java >Exit code: 0 >java DaysInMonth Enter month from 1-12: 10 Enter year: 2020 Its not print the result" v:shapes="Picture_x0020_87">

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

Students also viewed these Programming questions

Question

Focus on the interview.

Answered: 1 week ago

Question

Write short notes on Interviews.

Answered: 1 week ago