Question: what's wrong with my code? The objective of this problem is to be able to use the debugger tool in NetBeans to inspect code during

what's wrong with my code?what's wrong with my code? The objective of this problem is to

The objective of this problem is to be able to use the debugger tool in NetBeans to inspect code during execution.

This is what the output should be: be able to use the debugger tool in NetBeans to inspect code

This is the code:

package pkg1213debugginglab;

import java.util.Scanner; public class DebugExample { public static void main(String[] args) { // TODO code application logic here Scanner sc; System.out.println("Enter a number between 1 and 12"); sc = new Scanner(System.in); int monthNum= Integer.parseInt(sc.next()); if (monthNum / 2 == 0) { System.out.println("The month is Even"); } else { System.out.println("The month is Odd"); } // call method to return the name of the month String month = getMonthName(monthNum); System.out.println(month); //while loop to calculate time to new year int j = 0; int i = month; while (i != 0) { i += 1; j++; System.out.println("Calculating time to New Year..."); } System.out.println("Total months left for New Year:" + j); } private static String getMonthName(int num){ String month = ""; switch (num) { case 1: month = "January"; break; case 2: month = "February"; break; case 3: month = "March"; break; case 4: month = "April"; break; case 5: month = "May"; break; case 6: month = "June"; break; case 7: month = "July"; break; case 8: month = "August"; case 9: month = "September"; break; case 10: month = "October"; break; case 11: month = "November"; break; case 12: month = "December"; break; default: System.out.println("Invalid month."); break; } return month; } }

DebugExample - Apache NetBeans IDE 12.6

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!