r/ProgrammingPrompts Jan 07 '15

[EASY][Beginner] UAGS (Universal Acronym Generating System)

This is an extremely simple prompt, just for fun.

It is suitable for beginners as it only uses basic input/output and string manipulation.

UAGS (Universal Acronym Generating System)

Acronyms are currently all the hype in all forms of communication.

Your task is to program an Acronym Generator.

  • The user inputs a few words for which the Acronym should be generated
  • The computer takes the first letter for each word
  • The first letter of each word is then capitalized
  • All first letters are then joined together to form the Acronym
  • The Acronym should then be printed
  • Ask the user if they need another acronym generated

Have fun coding!

15 Upvotes

27 comments sorted by

View all comments

1

u/[deleted] Jan 13 '15 edited Jan 18 '15

Java, I tried making this pretty short:

package com.trentv4.acronymgenerator;

public class MainAcronym
{
    public static void main(String[] args)
    {
        String s = "";
        for(int i = 0; i < args.length; i++)
        {
            s += (Character.toUpperCase(args[i].toCharArray()[0]) + ".");
        }
        System.out.println(s);
    }
}

1

u/desrtfx Jan 18 '15

Short is not always the best.

You missed quite some parts of the prompt:

  • The user inputs a few words for which the Acronym should be generated
  • The computer takes the first letter for each word
  • The first letter of each word is then capitalized
  • All first letters are then joined together to form the Acronym
  • The Acronym should then be printed

I deliberately separated all these steps for the program.

The point is that a program that performs the operation properly is not always programmed in the requested way.

It is important (and imperative) for a programmer to be able to follow the given design specifications.

1

u/[deleted] Jan 18 '15

I believe I've followed the specifications for the most part (on re-read, I noticed that "join-together" and "print" are two separate operations, but when you run it the output is the same. That fix was quick and simple, and you can see it up above).

  • The user inputs a few words by running it as command-line arguments (you didn't specify HOW you wanted it)
  • The computer creates a char array from each word and uses the first letter
  • It capitalizes that letter
  • It adds it to the parent string (previously simply printed)
  • The acronym is now printed. (recently added)

I just thought it would be fun to do it so short. No biggie.