Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following Java method: public static void printDate(int day, int mo

ID: 3611210 • Letter: C

Question

Consider the following Java method:
public static void printDate(int day, int month, intyear) {         System.out.println("The dateis: " + day+ "/"+ month + "/" + year); } - Specify the names and types of the input parameters - Write the instructions corresponding to the invocation ofmethod             printDate(int day, int month, int year) whithin the main method below(inside the curly brackets). Usethe following values: 14 for the day, 2 for the month and 2008 for the year. - After that what will be the result of the previous methodinvocation(i.e. what will be printed in the output?) Be veryprecise in your answer -Now rewrite the code of method printDate( int day, int month,int year) so that it prints the year first, followed by the month,and finally the day. Please give all in steps with comments thanks Consider the following Java method:
public static void printDate(int day, int month, intyear) {         System.out.println("The dateis: " + day+ "/"+ month + "/" + year); } - Specify the names and types of the input parameters - Write the instructions corresponding to the invocation ofmethod             printDate(int day, int month, int year) whithin the main method below(inside the curly brackets). Usethe following values: 14 for the day, 2 for the month and 2008 for the year. - After that what will be the result of the previous methodinvocation(i.e. what will be printed in the output?) Be veryprecise in your answer -Now rewrite the code of method printDate( int day, int month,int year) so that it prints the year first, followed by the month,and finally the day. Please give all in steps with comments thanks

Explanation / Answer

- Specify the names and types of the inputparameters
Input parameters:
1) day   --type of day is int
2) month --type of month is int
3) year ---type of year is int

- Write the instructions corresponding to theinvocation of method printDate(int day, int month, int year) withinthe main method below(inside the curly brackets).
Use the following values: 14 for the day, 2 for the month and 2008for the year.


public static void main(String[] args){

printDate(14, 2, 2008); //this is the instructionfor the call printDate() in main
}//end of main



- After that what will be the result of the previousmethod invocation(i.e. what will be printed in the output?) Be veryprecise in your answer
The output is:
The date is: 14/2/2008


-Now rewrite the code of method printDate( int day, int month,int year) so that it prints the year first, followed by the month,and finally the day.

public static void printDate(int day, int month, intyear)
{
      System.out.println("The date is: " +year+ "/"+ month + "/" + day); /* here the year comes first in thesystem.out.println(), and then comes the month and finally theday.
Therefore year will be printed first and then month and thenday
*/

}



The total java code is given below:

import java.io.*;
import java.util.*;
import java.lang.*;


public class Date1{

public static void printDate(int day, int month, int year)
{
      System.out.println("The date is: " +day+ "/"+ month + "/" + year);
}
/*
public static void printDate(int day, int month, int year)
{
      System.out.println("The date is: " +year+ "/"+ month + "/" + day);
      //here the year comes first in thesystem.out.println(), and then comes the month and finally theday.
//Therefore year will be printed first and then month and thenday


}
*/


public static void main(String[] args){

printDate(14, 2, 2008);
}//end of main


}//end of Date1 class


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote