0

If i have this method: public static int numberMonth(int parseMonth, String leapYear)

how would i print it out in this method:

public static  void main(String[] args)
{
  Boolean correctDate = false;
  String date;

  while (!correctDate)
  {
    // It is OK to embed the way you called the method checkInput(getInput())
    // but for troubleshooting, it is easier for me to break into smaller steps.

    // Request Date and get user response
    date = getInput();

    // Verfiy that the date entered contains a valid........
    correctDate = checkInput(date);

    // Display meesage to user
    if (correctDate == true)
    {
      System.out.println("The date you entered is: " + date);
      System.out.println(numberMonth); 
      System.out.println("The numerical date: " );
    }
    else
    {
      System.out.println("Please enter valid date ");
    }
  }
}
Ken White
  • 123,280
  • 14
  • 225
  • 444
Max
  • 57
  • 1
  • 8

2 Answers2

2

Looking on your previous questions and code snippets I think you need to read something like Oracle/Sun Java Tutorial: http://download.oracle.com/javase/tutorial/java/index.html There are all answers in fact. And much more.

xappymah
  • 1,624
  • 10
  • 14
0

The correct way to do what you've asked is to change System.out.println(numberMonth) to the following:

System.out.println(numberMonth(anInt, aString));

Where anInt is an int and aString is a string. You could also do this with specific values, like so:

System.out.println(numberMonth(5, "leap"));

There's a much larger issue at play here, being that it seems you lack a foundation in the most basic aspects of Java syntax. I would highly recommend taking a class, checking out an online tutorial, or getting a book to learn the basics of computer programming in general and the Java language more specifically.

For instance, in your related question where you show the numberMonth function in detail, while a lot of things stand out, the most striking detail is using a String for your leapYear value. When you're dealing with information that is either true or false, you want to use the boolean data type. Boolean variables can only contain two values: true or false. So, rather than storing a string with the values "leap" or "no leap", you could declare a boolean variable. Here's a brief example:

public static int numberMonth(int parseMonth, boolean leapYear)
{
    if(leapYear)
    {
        //if leapYear is true, this code will be executed
    }
    else
    {
        //if leapYear is false, this block will be executed
    }
}

Take the time now to learn these basic, fundamental techniques. It will save you a mountain of frustration and wasted time in the future.

Community
  • 1
  • 1
jonmorgan
  • 2,570
  • 2
  • 22
  • 27
  • I am currently taking a class on java. This is a project I am currently working on implementing methods. The scope of the project is to take an input of MM/DD/YYYY and convert it into a month, day year and then the number of the date in a 365 number. if you want to look and see exaclty where I am coming from, I am more than willing to share the code with you – Max Mar 26 '11 at 18:08