Skip to content

Easy challenges #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Aug 12, 2021
Prev Previous commit
Next Next commit
Alphabet Soup
  • Loading branch information
ardallie committed Aug 9, 2021
commit 9efe9485b620fd920fcde2995290ded7127817c1
36 changes: 36 additions & 0 deletions src/easy/AlphabetSoup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package easy;

import java.util.Arrays;

/**
* Have the function AlphabetSoup(str) take the str string parameter being passed
* and return the string with the letters in alphabetical order (i.e. hello becomes ehllo).
* Assume numbers and punctuation symbols will not be included in the string.
*/
public class AlphabetSoup {

/**
* Alphabet Soup function.
*
* @param str input string
* @return the string with the letters in alphabetical order
*/
private static String alphabetSoup(String str) {
char[] letters = str.toCharArray();
Arrays.sort(letters);
return String.valueOf(letters);
}

/**
* Entry point.
*
* @param args command line arguments
*/
public static void main(String[] args) {
var result1 = alphabetSoup("leftfield");
System.out.println(result1);
var result2 = alphabetSoup("underworld");
System.out.println(result2);
}

}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy