where is the freakin tomcat?!?! February 20, 2006
Posted by Phillip in : geek , trackbackI am sitting in class wondering if we are ever going to stop talking about programming and start talking about Tomcat. I am getting frustrated with all of the java programing. I wish to learn how to do performance tuning on tomcat. Sorry I can’t say more about that right now. Here is a command-line java calculator:
public class Calc {
public static void main(String[] args) {
if (args.length < 2) {
System.err.println("Usage: Calc
return;
}
char op = args[0].charAt(0);
double result = Double.parseDouble(args[1]);
for (int i = 2; i < args.length; i++) {
double operand = Double.parseDouble(args[i]);
switch (op) {
case '+': result += operand; break;
case '-': result -= operand; break;
case '*': result *= operand; break;
case '/': result /= operand; break;
default: System.err.println("Invalid operator: " + op);
return;
}
}
System.out.println(result);
}
private static boolean isNumber(String s) {
return s.matches("(\\-|\\+)?[0-9]+(.[0-9]+)?");
}
}
Comments»
wp sux for code pasting.