The code below is currently displayed on the computer screen

The code below is currently displayed on the computer screen at Swagger Distribution every morning when employees log on to their computers. The new owner would like you to:

1.Add a second line that tells employees, “Welcome to Swagger Distribution!”

2.Place the “Welcome” statement above the current date.

3.Change the word “Current” to “Today’s” on the date output.

Rewrite the code to meet the new owner request.

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be \"Main\" only if the class is public. */

public class HelloWorld

{

public static void main (String[] args) throws java.lang.Exception

{

int day;

int month;

int year;

GregorianCalendar date = new GregorianCalendar();

day = date.get(Calendar.DAY_OF_MONTH);

month = date.get(Calendar.MONTH);

year = date.get(Calendar.YEAR);

System.out.println(\"Current date is \"+(month+1)+\"/\"+day+\"/\"+year);

}

}

·Identify the functionality of key code

components such as what the functionality of “system.out.println” is along with other code components such as the calendar code and the semicolon.

·Briefly summarize the three changes that were made from the original code for Swagger using the appropriate terminology.

·Add a screenshot of your code and output and paste into your document.

Solution

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be \"Main\" only if the class is public. */

public class HelloWorld

{

public static void main (String[] args) throws java.lang.Exception

{

int day;

int month;

int year;

GregorianCalendar date = new GregorianCalendar();

day = date.get(Calendar.DAY_OF_MONTH);

month = date.get(Calendar.MONTH);

year = date.get(Calendar.YEAR);

System.out.println(\"Welcome to Swagger Distribution!\");

System.out.println(\"Welcome, Today\'s date is \"+(month+1)+\"/\"+day+\"/\"+year);

}

}

The Changes are bolded.

system is predefined class in java.lang package and out is a static member of system class of printStream type and println is the method of printStream.

The code below is currently displayed on the computer screen at Swagger Distribution every morning when employees log on to their computers. The new owner would
The code below is currently displayed on the computer screen at Swagger Distribution every morning when employees log on to their computers. The new owner would

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site