Welcome to Dream.In.Code
Become a Java Expert!

Join 150,195 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,007 people online right now. Registration is fast and FREE... Join Now!




DateDriver

 
Reply to this topicStart new topic

DateDriver

gwiggins
24 Sep, 2008 - 08:18 AM
Post #1

New D.I.C Head
*

Joined: 4 Nov, 2007
Posts: 1


My Contributions
**********************************************************
*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
User is offlineProfile CardPM
+Quote Post

abgorn
RE: DateDriver
24 Sep, 2008 - 08:20 AM
Post #2

Hello Crap for Brains
Group Icon

Joined: 5 Jun, 2008
Posts: 912



Thanked: 5 times
Dream Kudos: 50
My Contributions
Could you please code.gif
User is offlineProfile CardPM
+Quote Post

pbl
RE: DateDriver
24 Sep, 2008 - 02:26 PM
Post #3

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
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...
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:32AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month