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 3 of 3

Thread: Listing the alphabet in lower and uppercase

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

    Default Listing the alphabet in lower and uppercase

    Ok, so basically I need to d this java application for an assignment. It says Write a java program that uses the ASCII codes and a for loop in a METHOD Alphabet() to display the alphabet in the following format.

    I'm not too good at java but this is what i got so far.

    {
    public static void main( String args[] )
    {
     
    char upper;
    char lower;
     
    System.out.printf( "%s%20s\n", "UPPERCASE", "LOWERCASE");
    for ( upper = 'A'; upper <= 'Z'; upper++ )
     
    {
    System.out.print(upper);
    System.out.println();
    }
     
     
     
    }
    }

    Problem is.. I'm not even using ASCII or the Alphabet method. I need some serious help here, and i know some of you might not one to help but to those who want your help will be appreciated.

    I also have it this other way;

    This way it shows the alphabet but i can't manage to but them in two different rows one saying UPPERCASE and the other saying lowercase

    public class Alphabet {
    public Alphabet() {
    for ( int i = 65; i < 91; i ++ ) {
    System.out.println("Upper Case\n"+(char)i + " " + (char)(i+32));
    }
    }
    public static void main(String [] args) {
    new Alphabet();
    }
    }

    The output has to be like this

    UPPERCASE lowercase
    A a
    B b
    C c
    . .
    . .
    . .
    Z z



    With the second code i already have a similar output... but i can't seem to add the headers UPPERCASE and lowercase.

    can anyone help me with this? Thanks in advanced.


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Listing the alphabet in lower and uppercase

    You need to output the headers before going into the loop, so they only get printed once.

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

    Default Re: Listing the alphabet in lower and uppercase

    Yeah i already solved it... for some reason i failed to realize that if i left the headers in the loop they would keep repeating themselves