Print the date using alphabetic format.

Assignment Help JAVA Programming
Reference no: EM13941091

Directions

The files must be named as below:
DateDriver.java (driver program)
Date.java (Date class file)
Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.
Overall Requirements
Create a class named Date that stores date values and prints out the date in either a pure numeric format or a name and number format (see sample session for format details).
Date.java class file

• Date objects should store the date in two int instance variables - day and month, and it should include the String instance variable, error, initialized with null.

• Implement a 1-parameter Date constructor that receives a dateStr string parameter and performs complete error checking on the given dateStr value. The Date constructor is the entity that's responsible for date error checking. That way, if a Date object is instantiated and if there are no errors, then you're guaranteed that the Date object holds a legitimate date value. If any kind of error occurs, change the value of the error instance variable to a non-null string value, using an appropriate concatenation of a string constant, input substring, and/or API exception message.

• Constructors use the same exception handling rules as methods: In a try block, include the parsing of the month and day substrings and other error-checking logic that will not work if parsing fails.

• Take into account the actual number of days in each month, but assume that there are always 28 days in February.

• To extract day and month numbers from the given date string, use String's indexOf method to find the location of the slash character, and String's substring method to extract month and day substrings from the input string.

• Include a method for printing the date with a numeric format. Use the zero-pad flag in a printf method call to get exactly two digits for each month and day.

• Include a method for printing the date with an alphabetic format.

• Include a getError method which returns the value of the error instance variable.
DateDriver.java class file
In your driver class, include a loop that repeatedly:

• Asks the user to enter a date or "q" to quit.

• If the entry is not "q", instantiate a Date object.

• If the error variable is null:

o Print the date using numeric format.

o Print the date using alphabetic format.

o Otherwise, print the value of the error variable.

Sample Session:

Enter a date in the form mm/dd ("q" to quit): 5/2
05/02
May 2
Enter a date in the form mm/dd ("q" to quit): 05/02
05/02
May 2
Enter a date in the form mm/dd ("q" to quit): 52
Invalid date format - 52
Enter a date in the form mm/dd ("q" to quit): 5.0/2
Invalid format - For input string: "5.0"
Enter a date in the form mm/dd ("q" to quit): 13/2
Invalid month - 13
Enter a date in the form mm/dd ("q" to quit): 2/x
Invalid format - For input string: "x"
Enter a date in the form mm/dd ("q" to quit): 2/30
Invalid day - 30
Enter a date in the form mm/dd ("q" to quit): 2/28
02/28
February 28
Enter a date in the form mm/dd ("q" to quit): q

Reference no: EM13941091

Questions Cloud

Calculate the monthly revenue for wallace motors for january : Wallace Motors, which began business on December 31, 2009, buys and sells used cars. Calculate the monthly revenue for Wallace Motors for January and February 2010.
Develop a project plan for the trial : You have been asked as an "outside contractor" to develop a project plan for the trial. The trial includes:
What is the level of production : What is the level of production, price, and total profit per week?
Research on induction procedures and program content : 1. Conduct research on induction procedures and program content. 2. Draft policy statement, objectives, program outline, procedures and documents for each stage of induction process that suit the organisation and comply with relevant legislation.
Print the date using alphabetic format. : Constructors use the same exception handling rules as methods: In a try block, include the parsing of the month and day substrings and other error-checking logic that will not work if parsing fails
Conservation strategy to australian volunteer tourists : Your task is to promote its conservation strategy to Australian volunteer tourists. You are required to conduct a literature review of about 500-800 words on the topic using keywords such as volunteer tourism, segmentation, targeting and positi..
Implement a plan to address recruitment and selection : Your role is to work as a consultant to a small business. You will need to identify a small business, a business with which you are familiar or a business agreed with your assessor and conduct research into that business' human resources needs (fo..
What is the slenderness ratio of a solid circular bar : What is the slenderness ratio of a solid circular bar 30 in. long and 2 in. in diameter - calculate the slenderness ratio of a rectangular bar 1.5 in. x ¾ in. and 20 in. long.
What would the equilibrium price and quantity : What would the equilibrium price and quantity be in a competitive industry? What would the social gain be if this monopolist were forced to produce and price at the competitive equilibrium?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write java program which simulates flipping of coin

Write a Java program which simulates flipping of coin 1000 times and prints total number of heads and tails. You should create a class.

  Implementing a binary tree write a generic implementation

Implementing a Binary Tree Write a generic implementation of a binary tree class using an internal node class TreeBinUMUC and NodeTreeBin

  Display the value stored at the index

Display the value stored at the index. Take a screenshot to verify that the words in your Array or ArrayList are displayed successfully.

  Mutator method for every instance variable of a class

Is it required to provide an accessor and/or mutator method for every instance variable of a class? If yes, explain why this is required, and if no, explain why not.

  Design the class line type to store a line

Design the class lineType to store aline. To store a line, you need to store the values of a (coefficient of x), b(coefficient of y), and c. Your class must contain the following operations.

  Write a java program that creates three threads

The reader-writer problem can be stated as given: A shared memory location can be concurrently read by any number of tasks, but when a task must write to the shared memory location, it must have exclusive access.

  Method that reads a text file and returns a list of tokens

Write a method that reads in a text file and returns a list of the tokens (preferably alphanumeric) in that file. Write a method to print out frequency results.

  Implement a game called bunko-poker

Implement a game called Bunko-Poker. The gameplay is an easily programmed version of the popular game Yahtzee. Your program will make use of the supplied static functions Dice.roll() and, in cases where you might need the string ordered, Dice.ordered..

  Writing a program to calculate state income tax

The second programming project involves writing a program to calculate state income tax for a single taxpayer that uses a GUI. The GUI should use the grid layout manager and should looks similar to the following: The salary income, interest income..

  Write a program that asks for purchase price

Write a program that asks for purchase price and to calculate, state sales tax, county sales tax and then display purchase price, both sales tax amount and then the total.

  Design a dynamic programming algorithm

Assume that at a station ti takes 2 hours to change horses and a horse takes (x ln x)/100 hours to travel x miles. Design a dynamic programming algorithm to determine a sequence of stations at which to stop so as to minimize the total hours.

  In this project you need to write a java program called

in this project you need to write a java program called mm.java to perform matrix multiplication. your code will read

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd