***INTERACTIVE DAYS-AND-MONTHS PROGRAM IN JAVA***

🔁 Creating an Interactive Java Program to Display Days and Months

🧑🏾‍💻 Introduction

Every great software journey begins with understanding how to communicate with users. Whether it’s through a GUI, a mobile app, or a simple command-line interface — a responsive, interactive program always stands out.

In this project, we build a loop-driven Java program that allows users to display either the days of the week or the months of the year, over and over again — without restarting. It's a console-based tool powered by Scanner and switch statements, perfect for beginners looking to master user input, logic control, and iteration.


🛠️ What This Program Does

This Java program allows the user to:

  1. Choose whether they want to view:

    • The days of the week, or

    • The months of the year

  2. Enter a number:

    • From 1 to 7 to display a weekday

    • From 1 to 12 to display a month

  3. Repeat this process infinitely, until they decide to terminate the program manually (via keyboard interrupt or custom exit logic).

This structure turns the program into an interactive calendar tool.


💡 How the System Works

Here’s the logic flow in plain English:

  1. A welcome message is displayed with two clear options:

    • Press 1 to see days of the week

    • Press 2 to see months of the year

  2. The user inputs a number.

  3. Depending on the choice:

    • If 1: Another number (1–7) is entered to show a weekday.

    • If 2: Another number (1–12) is entered to show a month.

  4. If any input is invalid, the program responds with an appropriate error message.

  5. The process repeats endlessly unless the program is forcefully exited.


🎓 Skills You’re Practicing

This program teaches some clutch Java fundamentals:

  • Looping with for(;;): A clean, infinite loop structure that acts like while(true)

  • Nested switch statements: For precise decision-making based on user input

  • Error handling: Informing users when their input isn’t valid

  • User interaction: How to write programs that actually "talk" to the user

  • Scanner class: The go-to class for reading input from users


🌍 Real-Life Application

While this might seem like a basic project, it's got real-world potential when extended:

  • 📅 Date and time pickers in mobile or web apps

  • 🧠 Educational tools for teaching months and weekdays

  • 📆 Custom CLI utilities for scheduling or reminders

  • 🌐 Localization logic: Adapting day/month labels to different languages

This is the kind of logic you’ll build on when you start writing calendar tools, booking systems, or even just clean UI menus.


💭 Final Thoughts

This program transforms a simple Java code snippet into a fully interactive command-line tool. It reinforces the idea that even beginner-friendly projects can be smart, polished, and user-centric.

You're not just printing days and months anymore — you're learning how to build programs that adapt, respond, and engage.

And that, my friend, is what good programming is all about.


import java.util.Scanner;
public class MonthWeek{
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        for(int i =0; ;){
        System.out.println("THIS PROGAM DISPAY BOTH THE DAYS OF THE WEEK AND THE MONTHS OF YEAR");
        System.out.println("CHOOSE FROM THE OPTIONS BELOW");
        System.out.println("1. TO DISPAY WEEK \n2. TO DISPAY MONTH");
        int num = input.nextInt();
        switch (num){
            case 1:
            System.out.println("WELCOME TO THE DAYS OF THE WEEK DISPLAYER");
            System.out.print("ENTER ANY NUMBER(1-7): ");
            int num1 = input.nextInt();
            switch(num1){
                case 1:
                System.out.println("SUNDAY");
                break;
                case 2:
                System.out.println("MONDAY");
                break;
                case 3:
                System.out.println("TUESDAY");
                break;
                case 4:
                System.out.println("WEDNESDAY");
                break;
                case 5:
                System.out.println("THURSDAY");
                break;
                case 6:
                System.out.println("FRIDAY");
                break;
                case 7:
                System.out.println("SATURDAY");
                break;
                default:
                System.out.println("NUMBER IS NOT WITHIN THE WEEK RANGE");            
            }
            break;
            case 2:
            System.out.println("WELCOME TO THE MONTH DISPLAYER");
            System.out.print("ENTER ANY NUMBER(1-12): ");
            int num2 = input.nextInt();
            switch (num2){
                case 1:
                System.out.println("JANUARY");
                break;
                case 2:
                System.out.println("FEBRUARY");
                break;
                case 3:
                System.out.println("MARCH");
                break;
                case 4:
                System.out.println("APRIL");
                break;
                case 5:
                System.out.println("MAY");
                break;
                case 6:
                System.out.println("JUNE");
                break;
                case 7:
                System.out.println("JULY");
                break;
                case 8:
                System.out.println("AUGUST");
                break;
                case 9:
                System.out.println("SEPTEMBER");
                break;
                case 10:
                System.out.println("OCTOBER");
                break;
                case 11:
                System.out.println("NOVEMBER");
                break;
                case 12:
                System.out.println("DECEMBER");
                break;
                default:
                System.out.println("NUMBER IS WITHIN THE MONTH RANGE");            
            }
            break;
            default:
            System.out.println("NUMBER NOT WITHIN THE ABOVE OPTION RANGE ");          
        }
    }
        input.close();
    }
}  

/*Name: Umaru Justin Rogers
ID: I- 24- 62999
INFORMATION TECHNOLOGY */

Comments

Popular posts from this blog

**" MILESTONE OF COMPUTING & PROGRAMMING LANGUAGE" **"SOFTWARE DEVELOPMENT PARADIGMS"

***Grading System for IPAM, University of Sierra Leone***