Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Anyone help me this code ?

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Anyone help me this code ?

    -Question 1:Question 1—Esperanto

    Esperanto is a language invented in the 1880s by L. L. Zamenhof. It was invented to "create an easy-to-learn and politically neutral language that would serve as a universal second language to foster peace and international understanding."1

    One of the benefits of designing your own language is that you can impose strict rules on the language. In this question, you will use the rules of Esperanto to identify the parts of speech of different words. The rules for identifying parts of speech in Esperanto are2:

    If the word ends in .. it is a(n)...
    a adjective
    o or on singular noun
    oj or ojn plural noun
    e adverb

    This means there are no exceptions in Esperanto, like how in English the plural of goose is geese and while you usually add 'ly' to the end of an adjective to make it an adverb, 'goodly' isn't an adverb.

    Write a program that accepts words in Esperanto, and identifies whether each is an adjective, singular noun, plural noun or adverb.

    Input: Use Scanner to accept input in this question. Prompt the user to input a word. If the user types in "cesi" ("quit" in Esperanto), the program should quit. Otherwise, it should accept the input and process it as a word in Esperanto. After processing the word, the user should be prompted to enter another word. Assume the user inputs the words entirely in lowercase and that all words are at least three letters long.

    Calculate and Output: Use System.out. for all output. Use the charAt() and length() methods to find the last (one or possibly two) characters and determine which part of speech (adverb, singular noun, plural noun or adverb) the word is. If the word is in none of the four categories, print out an error message telling the user that the part of speech cannot be identified. An execution of your program would look like this:

    Enter a word in Esperanto: komputilo
    komputilo is a singular noun.
    Enter a word in Esperanto: sciencon
    sciencon is a singular noun.
    Enter a word in Esperanto: cesi
    Programmed by [your name here].
    End of processing.



    Hand-in: Save your file using the naming conventions described in the beginning of the assignment. Upload your file using the web-based hand-in tool. Also, submit the output for the following input:

    komputilo
    sciencon
    bonege
    Javo
    programi
    cesi





    I got stuck from here , I could not compile , and I dont know where is the problem , Anyone help me out


    import java.util.Scanner;
    public class Esperanto{
        public static void main (String[]args){
     
            String komputilo;
            String sciencon;
            String bonege;
            String Javo;
            String programi;
            String cesi;
     
     
            Scanner kbd = new Scanner (System.in);
     
            System.out.println ("Enter a word in Esperanto:");
            komputilo = kbd.next();
     
            System.out.println ("Enter a word in Esperanto:");
            sciencon= kbd.next();
     
            System.out.println ("Enter a word in Esperanto:");
            bonege= kbd.next();
     
            System.out.println ("Enter a word in Esperanto:");
            Javo= kbd.next();
     
            System.out.println ("Enter a word in Esperanto:");
            programi= kbd.next();
     
            System.out.println ("Enter a word in Esperanto:");
            cesi= kbd.next();
     
            char userA = komputilo.charAt(8);
     
            if (userA == "a"){
                System.out.println (komputilo + " is a singular noun");
            }
        }
    }
    Last edited by JavaPF; October 19th, 2010 at 02:57 AM. Reason: Please use readable font size and highlight code tags


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Anyone help me this code ?

    The answer is still the same.
    http://www.javaprogrammingforums.com...bout-java.html

    Oh, and I've pointed out your new cross post on the Vietnamese forum too. As you said there, it's my right.

    db

  3. #3
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Anyone help me this code ?

    Yet another cross post
    Please help me fix my code ? - Java Forums

    db

  4. #4
    Junior Member
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Anyone help me this code ?

    I dont know why you waste your time so much to find some mistake of people to post somewhere and talk something like a kid , not mature at all . I really wantna know how to solve it (that why I post somewhere on some forum to find the answer ,because I like programming and i have no abilities about it ,then I asked) , If you are a true IT don't be like selfish or something like a kids , but indeed I think you are a spammer , exactly so . but it's okay , Thanks for your times to search my post (__")

  5. #5
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Anyone help me this code ?

    I think the main issue here is your approach to asking for help.
    I don't mind cross posting just as long as you learn from each reply received. If people are advising against posting in this way, then take note.
    It doesn't take much to keep people happy and get the help you need..

    The problem with your code is here:

            char userA = komputilo.charAt(8);
     
            if (userA == "a"){
                System.out.println (komputilo + " is a singular noun");
            }

    Incompatible operand types char and String

    You can fix it like this:

            char userA = komputilo.charAt(8);
            String myString = Character.toString(userA);
     
            if (myString.equals("a")){
                System.out.println (komputilo + " is a singular noun");
            }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.