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]);
}
}
Want to see the full answer?
Check out a sample textbook solutionChapter 13 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
- Write a FancyCar class to support basic operations such as drive, add gas, honk horn, and start engine. FancyCar.java is provided with method stubs. Follow each step to gradually complete all methods. Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main() method includes basic method calls. Add statements in main() as methods are completed to support development mode testing. Step 0. Declare private fields for miles driven as shown on the odometer (int), gallons of gas in tank (double), miles per gallon or MPG (double), driving capacity (double), and car model (String). Note the provided final variable indicates the gas tank capacity of 14.0 gallons. Step 1 (2 pts). 1) Complete the default constructor by initializing the odometer to five miles, tank is full of gas, miles per gallon is 24.0, and the model is "Old Clunker". 2)…arrow_forwardFind the error: daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(7): daily_sales[i] = float(input('Enter the sales for ' \ + day_of_week[i] + ': ')arrow_forwardFind the error: daily_sales = [0.0, 0,0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(7): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': ')arrow_forward
- Find the error: daily_sales = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] days_of_week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] for i in range(6): daily_sales[i] = float(input('Enter the sales for ' \ + days_of_week[i] + ': '))arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it and normalize it? Give two references with your answer.arrow_forwardWhat are the steps you will follow in order to check the database and fix any problems with it? Have in mind that you SHOULD normalize it as well. Consider that the database offline is not allowed since people are connected to it and personal data might be bridged and not secured. Provide three refernces with you answer.arrow_forward
- Should software manufacturers should be tolerant of the practice of software piracy in third-world countries to allow these countries an opportunity to move more quickly into the information age? Why or why not?arrow_forwardI would like to know about the features of Advanced Threat Protection (ATP), AMD-V, and domain name space (DNS).arrow_forwardPlease show the code for the Tikz figurearrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning