2 Replies - 2880 Views - Last Post: 24 September 2008 - 03:26 PM Rate Topic: -----

#1 gwiggins  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-November 07

DateDriver

Posted 24 September 2008 - 09:18 AM

**********************************************************
*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.
************************************************************/

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 September 2008 - 03:21 PM


Is This A Good Question/Topic? 0
  • +

Replies To: DateDriver

#2 abgorn  Icon User is offline

  • sudo apt-get install brain
  • member icon

Reputation: 30
  • View blog
  • Posts: 1,409
  • Joined: 05-June 08

Re: DateDriver

Posted 24 September 2008 - 09:20 AM

Could you please :code:
Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8315
  • View blog
  • Posts: 31,836
  • Joined: 06-March 08

Re: DateDriver

Posted 24 September 2008 - 03:26 PM

The constructor Date(String) which by the way is deprecated since years
returns a Date. You are trying to put this date in "dateValue" which is an int

dateValue.printDate().... there is no methot (printDate() or else) associated with an int...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1