Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
sq-buzz
import java.util.Arrays; import java.util.List; /** * WELCOME TO THE CODING TEST! */ class Rextester { /** * TODO: implement * Returns a String list containing each number from 0 to the specified value, * with the following exceptions: * For each multiple of 3, store "Swiss" instead of the number. * For each multiple of 5, store "Quote" instead of the number. * For numbers which are multiples of both 3 and 5, store "SwissQuote" instead of the number. * * @param upToAndIncluding the maximum number, including it * @return resulting String list */ private List<String> generateSwissQuoteList(int upToAndIncluding) { // replace with implementation return Arrays.asList("SwissQuote"); } /** * TODO: implement * @return the number of occurrences of the String <SwissQuote> in the provided list */ private long countSwissQuote(List<String> theList) { // replace with implementation return 0L; } /** * Run and check */ public static void main(String[] args) { Rextester test = new Rextester(); // run List<String> result = test.generateSwissQuoteList(100); // checks checkString("SwissQuote", result.get(0)); checkString("1", result.get(1)); checkString("Swiss", result.get(3)); checkString("Quote", result.get(5)); checkString("SwissQuote", result.get(15)); checkString("Quote", result.get(100)); // add a sneaky null to the list result.add(null); checkString("7", String.valueOf(test.countSwissQuote(result))); } private static void checkString(String expected, String actual) { if (expected.equals(actual)) { System.out.println("Check OK"); } else { System.out.println("Check FAILED, expected " + expected + " but got " + actual); } } }
run
|
edit
|
history
|
help
0
JAVA # DİZİ İLE EN BÜYÜK BULMA
preincrement1
Print Longest String
은행 입출금
Word pattern
hw1p1
"encryption"
Homework
PE #4
fizzbuzz