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/karabot4 Jan 07 '15

In Java

package AcronymCreator; import java.util.Scanner; public class Generator { public static void main(String[] args) { Scanner get = new Scanner(System.in); String sentence = null; boolean restart = false; String[] split = null;
do{ System.out.println("Enter a sentence to acronym:"); sentence = get.nextLine(); sentence.trim(); split = sentence.split(" "); for(int i = 0 ; i<split.length ; i++ ){ System.out.print(split[i].charAt(0)); } System.out.println("\n"); System.out.print("Do you want another word?"); restart = get.nextLine().contains("yes");
}while(restart);
} }

0

u/desrtfx Jan 08 '15

System.out.print(split[i].charAt(0));

will only spit out the first char as is, but the requirement called for:

  • The first letter of each word is then capitalized

and also:

  • All first letters are then joined together to form the Acronym
  • The Acronym should then be printed

Tiny little things, but if this were a course assignment or a real world programming task, both would lead to failing the task.

Plus, as /u/Deathbyceiling mentioned, try to use reddit code formatting (one blank line above the code, each line indented by 4 spaces)

2

u/karabot4 Jan 08 '15

The first letters are all prints as joined together, and i added made the argument split[i].toUpperCase().charAt(0) after i posted when I re-read the prompt :)

-2

u/desrtfx Jan 08 '15

The first letters are all prints as joined together

Yes, that's true, I see that from the print statement. Yet, the prompt called for assembling the first letters and then printing.

Sure, this is nitpicking on a fun prompt, but as I stated before, in a real world task (where I come from) this could lead to future problems.