Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
21
Task/Comma-quibbling/Java/comma-quibbling.java
Normal file
21
Task/Comma-quibbling/Java/comma-quibbling.java
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
public class Quibbler {
|
||||
|
||||
public static String quibble(String[] words) {
|
||||
String qText = "{";
|
||||
for(int wIndex = 0; wIndex < words.length; wIndex++) {
|
||||
qText += words[wIndex] + (wIndex == words.length-1 ? "" :
|
||||
wIndex == words.length-2 ? " and " :
|
||||
", ";
|
||||
}
|
||||
qText += "}";
|
||||
return qText;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(quibble(new String[]{}));
|
||||
System.out.println(quibble(new String[]{"ABC"}));
|
||||
System.out.println(quibble(new String[]{"ABC", "DEF"}));
|
||||
System.out.println(quibble(new String[]{"ABC", "DEF", "G"}));
|
||||
System.out.println(quibble(new String[]{"ABC", "DEF", "G", "H"}));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue