P1-P5: rewrite to match current syllabus

Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
2023-06-05 00:09:49 +05:30
parent 9006831163
commit 539adc94da
7 changed files with 209 additions and 214 deletions

22
P2.java
View File

@@ -1,11 +1,15 @@
class P2 {
public static void main(String[] _args) {
int a = 5, b, f;
b = f = a;
import java.util.StringTokenizer;
while (b-- > 1)
f *= b;
public class P2 {
public static void main(String[] args) {
String input = "Hello, I am Batu Khan and I am about to blow.";
StringTokenizer tokenizer = new StringTokenizer(input, " ,");
System.out.println(a + "! = " + f);
}
}
int i = 0;
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
System.out.println("Token " + ++i + ": " + token);
}
}
}