Create a class named date that stores date values

Assignment Help JAVA Programming
Reference no: EM131578714

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.

LastNameFirstNameDateDriver.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.

Reference no: EM131578714

Questions Cloud

Describe a specific made-up situation : For each of these possibilities, describe a specific made-up situation (what is the program, what are the classes) where it would be the right choice
Approaches taken by other languages : Defend your decision by outlining the advantages of the approach of the language that you chose and the disadvantages of the approaches taken by other languages
Write a program that reads numbers from the keyboard : Write a program that reads numbers from the keyboard into an array of type int[] - Your program should allow any number of numbers to be entered
Maximum amount of money rational person willing to pay : Suppose I offer to play the following game with you if you will pay me some money. You roll a die, and I give you a dollar for each dot that is on top.
Create a class named date that stores date values : 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
What is the year end-of-year book value : What is the year 1 end-of-year book value for a piece of farm equipment that cost $45,000, with a salvage value of $8,000 at the end of 6 years
How many times to you expect to have to roll two dice : How many times do you expect to have to flip a coin until you first see a head? Why? How many times to you expect to have to roll two dice until you see a sum.
Characteristic of programming languages : One characteristic of programming languages that varies widely from language to language is how parameters are passed.
Would anyone happen to have the major field testets : Would anyone happen to have the major field testets. computer science questions. Are there any study guides or dumps one could use.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Compute the amount of money earned

If you invest the amount of P at R% interest rate annually. In N years, your investment will be P[1-(R/100)N+1] / (1 – R/100). Accepts the input of P, R and N and compute the amount of money earned after N years using computer currency forma..

  Client server monitoring system project design

client server monitoring system project design. The server adminstation can send messages to the clients and DESIGN WITH JAVA NETBEANS AND GUI.

  Explain the meaning of array index out of bounds

Explain the meaning of "array index out of bounds".

  Write a simple java program that will read an array of info

write a simple java program that will read an array of information containing the information (Name, offence [between arson, assault or theft] and year of offence

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Text file containing the data

This program should begin by asking the user for the name of a text file containing the data. Then read the data which will be a line containing the dimensions of a 2 dimensional array followed by a 2 dimensional array of ints. Then perform variou..

  All your code should be in the main method

Write a Java test program, all your code should be in the main method, that asks the user for two numbers representing an investment value and interest rate

  Write a test program that creates an array

Write a test program that creates an array of ten strings, an array of ten integers, and an array of ten dates, and finds the largest string, integer, and date in the arrays.

  Instantiate a non-default orderprocessor object

Assignment you will need to instantiate (creat*) object(s) and invoke their instance methods to perform different tasks. The program is to keep track

  Data about a virtual memory system

You are given the following data about a virtual memory system: (a) The TLB can hold 1024 entries and can be accessed in 1 clock cycle (1 nsec).

  Write a program with an exception handler

Write a program with an exception handler that deals with nonnumeric operands; then write another program without using an exception handler to achieve the same objective.

  Create your own short and simple jdbc java code

Create your own short and simple JDBC Java code example that inserts 2 records into an Oracle table of your creation. Post your fully functional code along with screen shots demonstrating the successful running of it.

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