java programming help needed...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • anonin
    Juvenile Delinquent
    • Oct 2005
    • 2347

    java programming help needed...

    I have to write a java program for my class in uni, where the program is supposed to prompt the user to enter a 6 - letter word, then once that is done it has to print one or two sentences depending on whether the word has certain properties, for example:

    Affhin - the output would be : The letters Affhin are in ascending order.

    zxvrda - the output would be : The letters zxvrda are in descending order. The letters zxvrda are all lowercase.

    xxXxx - the output would be : the letters in xxXxx are all the same.

    QWERTY - the output would be : The letters QWERTY are all uppercase.

    but if the user entered QwertY - the output would be : There is nothing special about this word.

    so far i've written this

    import java.util.Scanner;

    public class program
    {
    public static void main (String[] args)
    {
    String Word;
    Char L1, L2, L3, L4, L5, L6
    Scanner keyboard = new Scanner (System.in);

    System.out.print ("Hello please enter a 6-letter word: ")
    Word = keyboard.nextLine();

    if (Word.length() > 6)
    {
    System.out.print ("Your word is too long "+ , +" please try again!")
    System.exit (0);
    }
    // end if

    if (Word.length() < 6)
    {
    System.out.print ("Your word is too short "+ , +" please try again!")
    System.exit (0);
    }
    // end if


    soo, having said all that, my question is if im on the right path, and if so how the hell do i write the rest of this program so that it works correctly.?

    any help is appreciated

    also, please keep in mind that this is a begenning java course, so any code thats too advanced will more than likely get me called out by the professor and result in a F. I'm mostly looking for something that a begennier would use and something thats simple

  • DragonFire
    Addiction started
    • Dec 2004
    • 359

    #2
    Re: java programming help needed...

    well for a bigginer u would just go for nested if conditions . . just for for example check the first letter for a certian condition , if it's true for then check the other until you finish the 6 letters and ofcourse you would break out of an if or you could use a flag as a value 1 or 0 to show if the the condition held true for all 6 letters or not or maybe after each if condition then check for the flag ..thats pretty long and going into circles and circles , but i guess that would be beginners shot ... O ya and you can also do an if condition to check how many letters the user has input or if you can know that by some return froma a java ready made function .. i am not sure .. if i sound so complicated ....well........ i think i can do this prog on c++ easily but i never used java before .. let me now how it goes
    Don't Immitate ... Innovate

    Comment

    • anonin
      Juvenile Delinquent
      • Oct 2005
      • 2347

      #3
      Re: java programming help needed...

      thanks bro! ill keep ya posted!

      Comment

      • Hos
        Are you Kidding me??
        • Jun 2004
        • 4286

        #4
        Re: java programming help needed...

        www.mercuryengine.com imo
        black is the new black www.mercuryserver.com

        Comment

        Working...