**********************************************************
*DateDriver.java (driver program)
*
*
*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).
*?
*DateDriver.java class file
*In your driver class,
*????????? If the error variable is null:
*
* ? Otherwise, print the value of the error variable.
************************************************************/
CODE
import java.util.*;
import java.util.Date;
public class DateDriver
{
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
int datevalue;
String value;
String error = null;
boolean quit;
do
{
System.out.print("Enter a date in the form mm/dd ('q' to quit): ");
value = stdIn.next();
if ((!value.equalsIgnoreCase("q")) || (!value.equals(" ")))
{
datevalue = new Date(value);
datevalue.printDate();
quit = false;
}
else
{
quit = true;
}
}//end loop
while (!quit);
}//end main
}//end class
For some reason when I declared the datevalue, it didn't like it. I think everything else is ok, does anyone mind helping me out?
This is what the error message says:
E:\DateDriver.java:36: incompatible types
found : java.util.Date
required: int
datevalue = new Date(value);
^
E:\DateDriver.java:37: int cannot be dereferenced
datevalue.printDate();
^
Note: E:\DateDriver.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
Tool completed with exit code 1
Edited to add the code tags
This post has been edited by pbl: 24 Sep, 2008 - 02:21 PM