Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
Question
Book Icon
Chapter 13.4, Problem 13.4.2CP
Program Plan Intro

abstract class:

An abstract class is a class which may or may not include abstract methods and cannot be instantiated but rather can be sub classed.

Program Code: 

Filename: TestCalendar.Java

//Import the packages

import java.util.*;

//class definition

public class TestCalendar

{

//main function definition

public static void main(String[] args)

{

/* Construct a Gregorian calendar for the current date and time*/

    Calendar calendar = new GregorianCalendar();

//print current time by using object Calender

System.out.println("Current time is " + new Date());

System.out.println("YEAR: " + calendar.get(Calendar.YEAR));

System.out.println("MONTH: " + calendar.get(Calendar.MONTH));

System.out.println("DATE: " + calendar.get(Calendar.DATE));

System.out.println("HOUR: " + calendar.get(Calendar.HOUR));

    System.out.println("HOUR_OF_DAY: " +

    calendar.get(Calendar.HOUR_OF_DAY));

System.out.println("MINUTE: " +  calendar.get(Calendar.MINUTE));

System.out.println("SECOND: " + calendar.get(Calendar.SECOND));

//print the current day of the week

System.out.println("DAY_OF_WEEK: " calendar.get(Calendar.DAY_OF_WEEK));

//print the current day of the month

    System.out.println("DAY_OF_MONTH: " +

     calendar.get(Calendar.DAY_OF_MONTH));

//print the current day of the year

    System.out.println("DAY_OF_YEAR: " +

     calendar.get(Calendar.DAY_OF_YEAR));

//print the current week of the month

    System.out.println("WEEK_OF_MONTH: " +

     calendar.get(Calendar.WEEK_OF_MONTH));

//print the current week of the year

    System.out.println("WEEK_OF_YEAR: " +

     calendar.get(Calendar.WEEK_OF_YEAR));

//print whether time is in A.M or P.M.

System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));

    // Construct a calendar for December 25, 1997

Calendar calendar1 = new GregorianCalendar(1997, 11, 25);

String[] dayNameOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"};

//print day of the week

    System.out.println("December 25, 1997 is a " +

        dayNameOfWeek[calendar1.get(Calendar.DAY_OF_WEEK) - 1]);

  }

}

Blurred answer
Students have asked these similar questions
[5 marks] Give a recursive definition for the language anb2n where n = 1, 2, 3, ... over the alphabet Ó={a, b}. 2) [12 marks] Consider the following languages over the alphabet ƒ={a ,b}, (i) The language of all words that begin and end an a (ii) The language where every a in a word is immediately followed by at least one b. (a) Express each as a Regular Expression (b) Draw an FA for each language (c) For Language (i), draw a TG using at most 3 states (d) For Language (ii), construct a CFG.
Question 1 Generate a random sample of standard lognormal data (rlnorm()) for sample size n = 100. Construct histogram estimates of density for this sample using Sturges’ Rule, Scott’s Normal Reference Rule, and the FD Rule. Question 2 Construct a frequency polygon density estimate for the sample in Question 1, using bin width determined by Sturges’ Rule.
Generate a random sample of standard lognormal data (rlnorm()) for sample size n = 100. Construct histogram estimates of density for this sample using Sturges’ Rule, Scott’s Normal Reference Rule, and the FD Rule.

Chapter 13 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package

Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning