Execute HQ9+/Java: Difference between revisions
m
Fixed syntax highlighting.
m (Lowercase-ing input) |
m (Fixed syntax highlighting.) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1:
{{implementation|HQ9+}}{{collection|RCHQ9+}}
This [[Java]] program accepts input from a file named by its first argument, or std in if no arguments are given.
<lang java>import java.io.BufferedReader;▼
Note: A [[Unicode]] trick could be done to make this source code a quine (similar to the one done in [[RCHQ9+/Tcl]], but also replacing the literal 99's with "100 - 1").
import java.io.FileReader;
import java.io.InputStreamReader;
Line 20 ⟶ 23:
for(char instr:code.toCharArray()){
switch(instr){
case 'q': System.out.println(code); break;
case 'h': System.out.println("Hello, World!"); break;
case '9': printBottles(); break;
case '+': acc++; break;
default: //ignore other chars
}
Line 44 ⟶ 47:
"1#One bottle|2#{0} bottles} of beer", n);
}
}</
|