Results 1 to 6 of 6
  1. #1
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default error on running java code

    hello guy im new here i want to ask on how to make this java code running for now it give me the error of could not find or load main class

    import java.util.Scanner;

    class counter {
    public static void main (String [] args) {

    //count 0 to 99


    System.out.println("please enter a number between 0 to 99:");

    Scanner input = new Scanner(System.in);
    }
    int no;{

    if (no<20) {


    if (no==0) {System.out.println("Zero");}

    else if (no==1) {System.out.println("One");}

    else if (no==2) {System.out.println("Two");}

    else if (no==3) {System.out.println("Three");}

    else if (no==4) {System.out.println("Four");}

    else if (no==5) {System.out.println("Five");}

    else if (no==6) {System.out.println("Six");}

    else if (no==7) {System.out.println("Seven");}

    else if (no==8) {System.out.println("Eight");}

    else if (no==9) {System.out.println("Nine");}

    else if (no==10) {System.out.println("Ten");}

    else if (no==11) {System.out.println("Eleven");}

    else if (no==12) {System.out.println("Twelve");}

    else if (no==13) {System.out.println("Thirteen");}

    else if (no==14) {System.out.println("Fourteen");}

    else if (no==15) {System.out.println("Fifthteen");}

    else if (no==16) {System.out.println("sixteen");}

    else if (no==17) {System.out.println("Seventeen");}

    else if (no==18) {System.out.println("eighteen");}

    else if (no==19) {System.out.println("nineteen");}

    }

    }

    }

    can sombody check how to make this work .

    what command do i need to make these happen

    any idea guys

    the problem for my code is : could not find or load main class

    im news to the java programming

    if this can work how to make like lets say 25 it should say twenty five (verbalized)

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,889
    Rep Power
    8

    Default Re: error on running java code

    When posting code, please use the code tags to preserve formatting. Also, code should be in the form of an SSCCE, not your whole program copy-pasted.

    How are you compiling this? How are you running it?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    adrianking is offline Member
    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0

    Default Re: error on running java code

    hope this code is fine for you

    spoonfeeding removed by moderator
    Last edited by KevinWorkman; 03-04-2013 at 05:49 PM. Reason: spoonfeeding != helping

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,889
    Rep Power
    8

    Default Re: error on running java code

    Quote Originally Posted by adrianking View Post
    hope this code is fine for you
    Attempting to spoonfeed and answer is NOT helping. Help the original poster debug the problem; don't just dump a full solution.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Jamil37037 is offline Member
    Join Date
    Feb 2013
    Location
    Islamabad, Pakistan
    Posts
    25
    Rep Power
    0

    Default Re: error on running java code

    Ok you have to do the following things:
    --> Add Scanner class in your program to remove compile time error
    --> Learn how to take input using Scanner class

    Hope you understand this .
    Firstly make object of scanner class and also intialize it as you did. Now use this object to take input from user in any data type.
    Java Code:
    Scanner obj=new Scanner(System.in);
    int option=obj.nextInt();
    double option=obj.nextDouble();
    String option=obj.nextLine();
    Hope you understand this. Also Use Java naming conventions as in Java Name of every class should start with capital letter so make Counter.

    Regards
    Jamil

  6. #6
    xhanis is offline Member
    Join Date
    Mar 2013
    Posts
    12
    Rep Power
    0

    Default Re: error on running java code

    Hope you understand this .
    Firstly make object of scanner class and also intialize it as you did. Now use this object to take input from user in any data type.

    Scanner obj=new Scanner(System.in);
    int option=obj.nextInt();
    double option=obj.nextDouble();
    String option=obj.nextLine();
    Hope you understand this. Also Use Java naming conventions as in Java Name of every class should start with capital letter so make Counter.


    jamil can you explain the other 4 for me

    for the class i know i should used capital letter

Similar Threads

  1. Java running error
    By distant_smile in forum New To Java
    Replies: 10
    Last Post: 01-23-2011, 06:19 AM
  2. java code running 24x7
    By namalsera in forum Advanced Java
    Replies: 2
    Last Post: 01-07-2011, 01:57 AM
  3. Java Code running problem
    By socboy6579 in forum New To Java
    Replies: 11
    Last Post: 10-26-2010, 04:07 AM
  4. error running java program
    By bdasilva in forum New To Java
    Replies: 1
    Last Post: 06-29-2009, 01:46 AM
  5. problem while running java code..
    By Jjava in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 06:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •