can you make a nonsensical program in java of at least 20 lines . Include an introduction about your motivations .
The program I present below is nonsensical and has no practical use. It is intended as an example of what a program might look like that has no clear purpose and does not perform useful functions. It is written in Java as it is a widely used programming language.
public class NonsenseProgram {
public static void main(String[] args) {
System.out.println("This is a nonsensical program.");
for (int i = 0; i < 10; i++) {
System.out.println(i + " times nonsensical!");
}
int x = 0;
while (x < 20) {
x++;
if (x % 2 == 0) {
System.out.println(x + " is an even number.");
} else {
System.out.println(x + " is an odd number.");
}
}
String s = "Nonsense";
for (int i = 0; i < 5; i++) {
s = s + "!";
System.out.println(s);
}
}
}
This program prints “This is a nonsensical program.” and then it counts from 0 to 9, each time "times nonsensical!" printing. Then it counts from 0 to 20 and prints whether the number is even or odd. Finally it prints “Nonsense!”, “Nonsense!!”, “Nonsense!!!”, “Nonsense!!!!” and “Nonsense!!!!!”.


Leave a Reply