Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-24-2004, 07:39 AM   PM User | #1
Johnny Redburn
New to the CF scene

 
Join Date: Apr 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Johnny Redburn is an unknown quantity at this point
New to java, problems.

Hi,
Im having a problem running .java programs in cmd prompt, its compiles ok but when i go to run it, example -->(java prac8prog1)
it brings up the following error:
"Exception in thread "main" java.lang.NoSuchMethodError: main"
Im using a JAR file ( import B102.*; ) at the top of my programs, that I was told to use, could this be whats the causing the error?

Also I need some help with a different program I have to do, I need to know how to set out a character array for the 26 letters in the alphabet. Im pretty sure what i started doing below is wrong and i need some advice

(This is the question im answering)
"Write a Java program which reads in a string from the keyboard and then reports how many times each letter of the alphabet occurs within that string (ignoring case). It should also report how many non-letters are included in the string."


Code:
class Assignment2prog1
{
    public static void UserInput()
    {
        public String Data = new String()
        Screen.out.println("Please enter a series of character values from the keyboard: ");
        String.toLowerCase()
        Data=keybd.in.readchar();
        return Data;
    }

    public static void Calculate()
    {
    	private char calcArray[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    	private int index;
        //??
        for(index=0; i<?; index++)
    }

    public static void Display()
    {

    }
/*******************************************************************************
********************************************************************************
			  MAIN PROGRAM STARTS HERE
********************************************************************************
*******************************************************************************/

    public static void Main(string args[])
    {
    	int Input=0
    	
    	Input = UserInput();
    }
}

/*******************************************************************************
********************************************************************************
			  MAIN PROGRAM ENDS HERE
********************************************************************************
*******************************************************************************/
Any help would be greatly appreciated.
Thanks.
Johnny Redburn is offline   Reply With Quote
Old 05-24-2004, 08:17 AM   PM User | #2
shmoove
Regular Coder

 
Join Date: Dec 2003
Posts: 367
Thanks: 0
Thanked 0 Times in 0 Posts
shmoove is an unknown quantity at this point
The name of the entry point function should be main() and not Main().

shmoove
shmoove is offline   Reply With Quote
Old 05-24-2004, 11:37 AM   PM User | #3
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,220
Thanks: 4
Thanked 80 Times in 79 Posts
Spookster will become famous soon enough
and it should be String args[] not string args[]. Watch your capitalization as Java is a case sensitive language.

As far as your second program since this does appear to be a homework assignment we cannot write or give any code to you. You must write it yourself but we can answer specific questions. I would suggest consulting your instructor first on what you've done so far. Honestly there is so much wrong with it right now I don't even know where to begin. I'll point out just a few areas you should probably read through your textbook or class notes on.

-Review how loops work, specifically "for" loops.
-Review the difference between declaring a method or data member public or private
-Review proper Java naming conventions specifically in the area of capitalization. When to capitalize a variable name or method name
-Review what instantiable classes are and how to implement them.
-Review how to read in input from the user and how to output to the screen. Hint...it's System.out.println no Screen.out.println. For the input you will need to use some kind of input reading class or combination of classes. There are several to choose from.
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:23 AM.


Advertisement
Log in to turn off these ads.