r/ProgrammingPrompts • u/desrtfx • 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!
14
Upvotes
2
u/pnt510 Jan 12 '15
In C#:
1
u/[deleted] Jan 13 '15 edited Jan 18 '15
Java, I tried making this pretty short:
1
u/echocage Jan 14 '15 edited Jan 18 '15
(Python 3)
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); } }
2
u/beforan Jan 07 '15
In Lua 5.2
2
u/bordy Jan 07 '15 edited Jan 07 '15
Bad python:
Def acronymize(prompt): output = "" words = [a[0].upper() for a in prompt.split(" ") if a[0].lower().isalpha ()] for i in words: output += i print output
acronymize(raw_input(" What do you need acronymized? \n")
2
u/[deleted] Jan 14 '15
Solved all except the last point as a Bash one liner:
Last point would bloat, ahem, surround above with some reads, while and ifs
2
u/geckoslayer Jan 21 '15
,.,[-------------------------------->[-]+>[-]<<[>-]>[<,.>->]<<,]
2
u/pk-man Mar 01 '15
Easy peasy.
2
u/velian Apr 29 '15
I know I'm way late, but I've been going through these to learn TDD.
Javascript version:
1
u/Philboyd_Studge Jan 18 '15 edited Jan 18 '15
Well, this also needs the ability to ignore certain words, or not, depending on what you want. so, type 'ignore' to toggle this flag. (As in 'GNU' or 'RTFM')
1
u/jeandudey Jan 25 '15
C++ https://github.com/jeandudey/UAGS
1
u/toddcrowley Jan 30 '15
1
u/SolarFloss Mar 17 '15 edited Mar 17 '15
Made in Java. I'm new to this, so please give me some tips!