Help Java novice

Discussion in 'Java' started by JavaNovice, Nov 5, 2006.

  1. JavaNovice

    JavaNovice Guest

    Hi All,

    I am new to this group and new to Java. Currently i am only six weeks
    into a course. I am studying bioinformatics. Anyway i am working my way
    through Java for dummies along side the coursework i am being set but i
    have come to a roadblock.

    I am trying to run the following code:-
    import java.util.Scanner;
    import static java.lang.System.out;


    class ScoreBoard{

    public static void main(String args[]){
    Scanner myScanner = new Scanner(System.in);
    int hankees, socks;
    WhoWins who;

    out.print("Hankees and Socks scores? ");
    hankees = myScanner.nextInt();
    socks = myScanner.nextInt();
    out.println();

    if (hankees > socks){
    who = WhoWins.home;
    out.println("The hankees win :)");
    } else if (socks > hankees){
    who = WhoWins.visitor;
    out.println("The socks win :-(");
    } else {
    who = WhoWins.neither;
    out.println("It's a tie :-|");
    }

    out.println();
    out.println("Today's game is brought to you by");
    out.println("SnitSoft, the number one software");
    out.println("vendor in the Hankeevilee area.");
    out.println("SnitSoft is featured proudly in");
    out.println("Chapter 6. and remember, four out");
    out.println("of five doctors recommend SnitSoft");
    out.println("to their patients.");
    out.println();

    if (who == WhoWins.home){
    out.println("We beat 'em good. Didin't we?");
    }
    if (who == WhoWins.visitor){
    out.println("The umpire made an unfair call. ");
    }
    if (who == WhoWins.neither){
    out.println("The game goes into overtime.");
    }


    }


    }
    But the compiler cannot find WhoWins enum type. I have installed the
    latest jdk-6-beta2 with the relevent API documents and still no joy. I
    was using jdk-1_5 with relevent API. I can just skip enum types but i
    would rather get to the bottom of this. Also, i went onto Java sun
    tutorials and copied and pasted their example of the enum type Day in a
    piece of code into my complier. Again the same problen ; cannot find
    symbol class Day. Help please i have exhausted all possibilities and i
    am now just left scratching my very sore head.

    Thanks
    Sarah
    xx
    JavaNovice, Nov 5, 2006
    #1
    1. Advertising

  2. JavaNovice

    JanTheKing Guest

    Sarah,

    Can you paste the compiler error in your post? Also provide the code
    for the WhoWins enum.

    Jan

    JavaNovice wrote:
    > Hi All,
    >
    > I am new to this group and new to Java. Currently i am only six weeks
    > into a course. I am studying bioinformatics. Anyway i am working my way
    > through Java for dummies along side the coursework i am being set but i
    > have come to a roadblock.
    >
    > I am trying to run the following code:-
    > import java.util.Scanner;
    > import static java.lang.System.out;
    >
    >
    > class ScoreBoard{
    >
    > public static void main(String args[]){
    > Scanner myScanner = new Scanner(System.in);
    > int hankees, socks;
    > WhoWins who;
    >
    > out.print("Hankees and Socks scores? ");
    > hankees = myScanner.nextInt();
    > socks = myScanner.nextInt();
    > out.println();
    >
    > if (hankees > socks){
    > who = WhoWins.home;
    > out.println("The hankees win :)");
    > } else if (socks > hankees){
    > who = WhoWins.visitor;
    > out.println("The socks win :-(");
    > } else {
    > who = WhoWins.neither;
    > out.println("It's a tie :-|");
    > }
    >
    > out.println();
    > out.println("Today's game is brought to you by");
    > out.println("SnitSoft, the number one software");
    > out.println("vendor in the Hankeevilee area.");
    > out.println("SnitSoft is featured proudly in");
    > out.println("Chapter 6. and remember, four out");
    > out.println("of five doctors recommend SnitSoft");
    > out.println("to their patients.");
    > out.println();
    >
    > if (who == WhoWins.home){
    > out.println("We beat 'em good. Didin't we?");
    > }
    > if (who == WhoWins.visitor){
    > out.println("The umpire made an unfair call. ");
    > }
    > if (who == WhoWins.neither){
    > out.println("The game goes into overtime.");
    > }
    >
    >
    > }
    >
    >
    > }
    > But the compiler cannot find WhoWins enum type. I have installed the
    > latest jdk-6-beta2 with the relevent API documents and still no joy. I
    > was using jdk-1_5 with relevent API. I can just skip enum types but i
    > would rather get to the bottom of this. Also, i went onto Java sun
    > tutorials and copied and pasted their example of the enum type Day in a
    > piece of code into my complier. Again the same problen ; cannot find
    > symbol class Day. Help please i have exhausted all possibilities and i
    > am now just left scratching my very sore head.
    >
    > Thanks
    > Sarah
    > xx
    JanTheKing, Nov 5, 2006
    #2
    1. Advertising

  3. JavaNovice

    JavaNovice Guest

    Hi JanTheKing,

    I have managed to get the code to compile but i am getting the
    following error message :-


    Welcome to DrJava. Working directory is C:\Documents and
    Settings\Steven\Desktop\Sarah Programming\Java
    > java WhoWins

    Error: No 'main' method in 'WhoWins' with arguments:
    ([Ljava.lang.String;)
    >

    Sarah


    JanTheKing wrote:
    > Sarah,
    >
    > Can you paste the compiler error in your post? Also provide the code
    > for the WhoWins enum.
    >
    > Jan
    >
    > JavaNovice wrote:
    > > Hi All,
    > >
    > > I am new to this group and new to Java. Currently i am only six weeks
    > > into a course. I am studying bioinformatics. Anyway i am working my way
    > > through Java for dummies along side the coursework i am being set but i
    > > have come to a roadblock.
    > >
    > > I am trying to run the following code:-
    > > import java.util.Scanner;
    > > import static java.lang.System.out;
    > >
    > >
    > > class ScoreBoard{
    > >
    > > public static void main(String args[]){
    > > Scanner myScanner = new Scanner(System.in);
    > > int hankees, socks;
    > > WhoWins who;
    > >
    > > out.print("Hankees and Socks scores? ");
    > > hankees = myScanner.nextInt();
    > > socks = myScanner.nextInt();
    > > out.println();
    > >
    > > if (hankees > socks){
    > > who = WhoWins.home;
    > > out.println("The hankees win :)");
    > > } else if (socks > hankees){
    > > who = WhoWins.visitor;
    > > out.println("The socks win :-(");
    > > } else {
    > > who = WhoWins.neither;
    > > out.println("It's a tie :-|");
    > > }
    > >
    > > out.println();
    > > out.println("Today's game is brought to you by");
    > > out.println("SnitSoft, the number one software");
    > > out.println("vendor in the Hankeevilee area.");
    > > out.println("SnitSoft is featured proudly in");
    > > out.println("Chapter 6. and remember, four out");
    > > out.println("of five doctors recommend SnitSoft");
    > > out.println("to their patients.");
    > > out.println();
    > >
    > > if (who == WhoWins.home){
    > > out.println("We beat 'em good. Didin't we?");
    > > }
    > > if (who == WhoWins.visitor){
    > > out.println("The umpire made an unfair call. ");
    > > }
    > > if (who == WhoWins.neither){
    > > out.println("The game goes into overtime.");
    > > }
    > >
    > >
    > > }
    > >
    > >
    > > }
    > > But the compiler cannot find WhoWins enum type. I have installed the
    > > latest jdk-6-beta2 with the relevent API documents and still no joy. I
    > > was using jdk-1_5 with relevent API. I can just skip enum types but i
    > > would rather get to the bottom of this. Also, i went onto Java sun
    > > tutorials and copied and pasted their example of the enum type Day in a
    > > piece of code into my complier. Again the same problen ; cannot find
    > > symbol class Day. Help please i have exhausted all possibilities and i
    > > am now just left scratching my very sore head.
    > >
    > > Thanks
    > > Sarah
    > > xx
    JavaNovice, Nov 5, 2006
    #3
  4. JavaNovice wrote:
    > Hi JanTheKing,
    >
    > I have managed to get the code to compile but i am getting the
    > following error message :-
    >
    >
    > Welcome to DrJava. Working directory is C:\Documents and
    > Settings\Steven\Desktop\Sarah Programming\Java
    >> java WhoWins

    > Error: No 'main' method in 'WhoWins' with arguments:
    > ([Ljava.lang.String;)
    > Sarah
    >

    You have to run the class containing the main() method, so start it with

    java ScoreBoard


    --
    martin@ | Martin Gregorie
    gregorie. | Essex, UK
    org |
    Martin Gregorie, Nov 5, 2006
    #4
  5. JavaNovice

    IchBin Guest

    JavaNovice wrote:
    > Hi JanTheKing,
    >
    > I have managed to get the code to compile but i am getting the
    > following error message :-
    >
    >
    > Welcome to DrJava. Working directory is C:\Documents and
    > Settings\Steven\Desktop\Sarah Programming\Java
    >> java WhoWins

    > Error: No 'main' method in 'WhoWins' with arguments:
    > ([Ljava.lang.String;)
    > Sarah
    >
    >
    > JanTheKing wrote:
    >> Sarah,
    >>
    >> Can you paste the compiler error in your post? Also provide the code
    >> for the WhoWins enum.
    >>
    >> Jan
    >>
    >> JavaNovice wrote:
    >>> Hi All,
    >>>
    >>> I am new to this group and new to Java. Currently i am only six weeks
    >>> into a course. I am studying bioinformatics. Anyway i am working my way
    >>> through Java for dummies along side the coursework i am being set but i
    >>> have come to a roadblock.
    >>>
    >>> I am trying to run the following code:-
    >>> import java.util.Scanner;
    >>> import static java.lang.System.out;
    >>>
    >>>
    >>> class ScoreBoard{
    >>>
    >>> public static void main(String args[]){
    >>> Scanner myScanner = new Scanner(System.in);
    >>> int hankees, socks;
    >>> WhoWins who;
    >>>
    >>> out.print("Hankees and Socks scores? ");
    >>> hankees = myScanner.nextInt();
    >>> socks = myScanner.nextInt();
    >>> out.println();
    >>>
    >>> if (hankees > socks){
    >>> who = WhoWins.home;
    >>> out.println("The hankees win :)");
    >>> } else if (socks > hankees){
    >>> who = WhoWins.visitor;
    >>> out.println("The socks win :-(");
    >>> } else {
    >>> who = WhoWins.neither;
    >>> out.println("It's a tie :-|");
    >>> }
    >>>
    >>> out.println();
    >>> out.println("Today's game is brought to you by");
    >>> out.println("SnitSoft, the number one software");
    >>> out.println("vendor in the Hankeevilee area.");
    >>> out.println("SnitSoft is featured proudly in");
    >>> out.println("Chapter 6. and remember, four out");
    >>> out.println("of five doctors recommend SnitSoft");
    >>> out.println("to their patients.");
    >>> out.println();
    >>>
    >>> if (who == WhoWins.home){
    >>> out.println("We beat 'em good. Didin't we?");
    >>> }
    >>> if (who == WhoWins.visitor){
    >>> out.println("The umpire made an unfair call. ");
    >>> }
    >>> if (who == WhoWins.neither){
    >>> out.println("The game goes into overtime.");
    >>> }
    >>>
    >>>
    >>> }
    >>>
    >>>
    >>> }
    >>> But the compiler cannot find WhoWins enum type. I have installed the
    >>> latest jdk-6-beta2 with the relevent API documents and still no joy. I
    >>> was using jdk-1_5 with relevent API. I can just skip enum types but i
    >>> would rather get to the bottom of this. Also, i went onto Java sun
    >>> tutorials and copied and pasted their example of the enum type Day in a
    >>> piece of code into my complier. Again the same problen ; cannot find
    >>> symbol class Day. Help please i have exhausted all possibilities and i
    >>> am now just left scratching my very sore head.
    >>>
    >>> Thanks
    >>> Sarah
    >>> xx

    >

    Sarah, as JanTheKing asked: What does your WhoWins class look like?

    --
    Thanks in Advance... http://ichbin.9999mb.com
    IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
    ______________________________________________________________________
    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
    IchBin, Nov 5, 2006
    #5
  6. JavaNovice

    JavaNovice Guest

    Hi JanTheKing,

    Sorry if i am being thick. But what do you mean, what does WhoWins look
    like?

    Sarah
    IchBin wrote:
    > JavaNovice wrote:
    > > Hi JanTheKing,
    > >
    > > I have managed to get the code to compile but i am getting the
    > > following error message :-
    > >
    > >
    > > Welcome to DrJava. Working directory is C:\Documents and
    > > Settings\Steven\Desktop\Sarah Programming\Java
    > >> java WhoWins

    > > Error: No 'main' method in 'WhoWins' with arguments:
    > > ([Ljava.lang.String;)
    > > Sarah
    > >
    > >
    > > JanTheKing wrote:
    > >> Sarah,
    > >>
    > >> Can you paste the compiler error in your post? Also provide the code
    > >> for the WhoWins enum.
    > >>
    > >> Jan
    > >>
    > >> JavaNovice wrote:
    > >>> Hi All,
    > >>>
    > >>> I am new to this group and new to Java. Currently i am only six weeks
    > >>> into a course. I am studying bioinformatics. Anyway i am working my way
    > >>> through Java for dummies along side the coursework i am being set but i
    > >>> have come to a roadblock.
    > >>>
    > >>> I am trying to run the following code:-
    > >>> import java.util.Scanner;
    > >>> import static java.lang.System.out;
    > >>>
    > >>>
    > >>> class ScoreBoard{
    > >>>
    > >>> public static void main(String args[]){
    > >>> Scanner myScanner = new Scanner(System.in);
    > >>> int hankees, socks;
    > >>> WhoWins who;
    > >>>
    > >>> out.print("Hankees and Socks scores? ");
    > >>> hankees = myScanner.nextInt();
    > >>> socks = myScanner.nextInt();
    > >>> out.println();
    > >>>
    > >>> if (hankees > socks){
    > >>> who = WhoWins.home;
    > >>> out.println("The hankees win :)");
    > >>> } else if (socks > hankees){
    > >>> who = WhoWins.visitor;
    > >>> out.println("The socks win :-(");
    > >>> } else {
    > >>> who = WhoWins.neither;
    > >>> out.println("It's a tie :-|");
    > >>> }
    > >>>
    > >>> out.println();
    > >>> out.println("Today's game is brought to you by");
    > >>> out.println("SnitSoft, the number one software");
    > >>> out.println("vendor in the Hankeevilee area.");
    > >>> out.println("SnitSoft is featured proudly in");
    > >>> out.println("Chapter 6. and remember, four out");
    > >>> out.println("of five doctors recommend SnitSoft");
    > >>> out.println("to their patients.");
    > >>> out.println();
    > >>>
    > >>> if (who == WhoWins.home){
    > >>> out.println("We beat 'em good. Didin't we?");
    > >>> }
    > >>> if (who == WhoWins.visitor){
    > >>> out.println("The umpire made an unfair call. ");
    > >>> }
    > >>> if (who == WhoWins.neither){
    > >>> out.println("The game goes into overtime.");
    > >>> }
    > >>>
    > >>>
    > >>> }
    > >>>
    > >>>
    > >>> }
    > >>> But the compiler cannot find WhoWins enum type. I have installed the
    > >>> latest jdk-6-beta2 with the relevent API documents and still no joy. I
    > >>> was using jdk-1_5 with relevent API. I can just skip enum types but i
    > >>> would rather get to the bottom of this. Also, i went onto Java sun
    > >>> tutorials and copied and pasted their example of the enum type Day in a
    > >>> piece of code into my complier. Again the same problen ; cannot find
    > >>> symbol class Day. Help please i have exhausted all possibilities and i
    > >>> am now just left scratching my very sore head.
    > >>>
    > >>> Thanks
    > >>> Sarah
    > >>> xx

    > >

    > Sarah, as JanTheKing asked: What does your WhoWins class look like?
    >
    > --
    > Thanks in Advance... http://ichbin.9999mb.com
    > IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
    > ______________________________________________________________________
    > 'If there is one, Knowledge is the "Fountain of Youth"'
    > -William E. Taylor, Regular Guy (1952-)
    JavaNovice, Nov 5, 2006
    #6
  7. JavaNovice

    Daniel Pitts Guest

    JavaNovice wrote:
    > Hi JanTheKing,
    >
    > Sorry if i am being thick. But what do you mean, what does WhoWins look
    > like?
    >


    First, please don't top post.
    What does WhoWins look like? It looks like the contents of the
    WhoWins.java file. Because WhoWins is not a standard API somewhere, it
    would have been useful for us to see its contents.

    Anyway, as someone else has pointed out. you need to run "java
    ScoreBoard", as ScoreBoard is the java class that has a "public static
    void main(String[])" method
    Daniel Pitts, Nov 5, 2006
    #7
  8. JavaNovice

    Simon Brooke Guest

    in message <>,
    JavaNovice ('') wrote:

    > IchBin wrote:
    >> JavaNovice wrote:
    >> >>> public static void main(String args[]){
    >> >>> Scanner myScanner = new Scanner(System.in);
    >> >>> int hankees, socks;
    >> >>> WhoWins who;


    ....

    >> >>> who = WhoWins.home;

    ....
    >> >>> who = WhoWins.visitor;

    ....
    >> >>> who = WhoWins.neither;

    ....
    >> >>> But the compiler cannot find WhoWins enum type.

    ^^^^^^^ ^^^^ ^^^^

    >> >

    >> Sarah, as JanTheKing asked: What does your WhoWins class look like?

    >
    > Sorry if i am being thick. But what do you mean, what does WhoWins look
    > like?


    I think she's using an enum type called WhoWins, not a class. Still, could
    we see the definition of it, please?

    --
    (Simon Brooke) http://www.jasmine.org.uk/~simon/

    Error 1109: There is no message for this error
    Simon Brooke, Nov 5, 2006
    #8
  9. JavaNovice

    Daniel Pitts Guest

    Simon Brooke wrote:
    > I think she's using an enum type called WhoWins, not a class. Still, could
    > we see the definition of it, please?


    Actually, in Java, an enum type is a class. But yes, we are all asking
    for the definition of WhoWins.
    Daniel Pitts, Nov 5, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gilgantic
    Replies:
    0
    Views:
    306
    gilgantic
    Feb 10, 2004
  2. Paul Drake
    Replies:
    2
    Views:
    374
    Starshine Moonbeam
    Jun 14, 2005
  3. java_killer
    Replies:
    4
    Views:
    955
    Kevin McMurtrie
    May 10, 2008
  4. java_killer
    Replies:
    0
    Views:
    454
    java_killer
    May 9, 2008
  5. Replies:
    63
    Views:
    2,051
    Mike Schilling
    Aug 26, 2009
Loading...

Share This Page