onox37 Posted January 13, 2008 Share Posted January 13, 2008 I need to know what it does and how to finish it. My friend gave it to me for a challenge because I told him I knew javascript and I have no idea what it is. package ConsoleApplication1; import java.math.*; import java.util.*; import java.io.*; /** * Summary description for Program */ public class Program { public static void main(String[] args) throws IOException { BufferedReader console = new BufferedReader(new InputStreamReader(System.in)); String input = console.readLine(); int i = 0; String out = ""; int cof; int power; int l = input.length(); while (i <= l - 1) { cof = 0; power = 0; if (input.charAt(i) == '+') { out = ""; } if (input.charAt(i) == 'x') { //shasfjdlkvhasjlkvhjklhlvhjlhvjashvjklhalashdvjklasdhvjklhghg //System.out.println(out); if (out == "cos") { System.out.print("-sin"); } //asvdhjkasghdvjgvvhgggdjklshdjklsdhfjklshdfjklasdhflsdhflkah try { cof = Integer.parseInt(out); } catch (NumberFormatException e) { } i++; if (input.charAt(i) == '^') { out = ""; i++; while (input.charAt(i) != '+' && i <= l - 1) { out += input.charAt(i); i++; } power = Integer.parseInt(out); cof *= power; power -= 1; System.out.print(cof); System.out.print("x^"); System.out.print(power); if (i != l - 1) { System.out.print("+"); } } else { System.out.print(cof); if (i != l - 1) { System.out.print("+"); } } out = ""; } String f = "1"; int g; //try //{f+=input.charAt(i); //g=Integer.parseInt(f); out += input.charAt(i);//} //catch (NumberFormatException e){} i++; } input = console.readLine(); } } Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 13, 2008 Share Posted January 13, 2008 My friend gave it to me for a challenge because I told him I knew javascript and I have no idea what it is. Why did you take the challenge, if you knew nothing about the code your friend was challenging to complete? That wasn't very smart was of you to do. ??? This looks allot like vb.net to me; but I could be wrong - it's been a long time since I had that class in college. Good Luck With Your Challenge! Quote Link to comment Share on other sites More sharing options...
xenophobia Posted January 13, 2008 Share Posted January 13, 2008 hey dude, that is java not javascript. what is the prize for that challenge? Haha... Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 13, 2008 Share Posted January 13, 2008 I though it could possibly be java, but I wasn't sure; never learned java. Quote Link to comment Share on other sites More sharing options...
jos. Posted January 13, 2008 Share Posted January 13, 2008 I am pretty sure that It is a primitive calculator..... Maybe not... I think it just spits out what ever you put in ... tell you friend that he should learn better variable naming practices. Jos. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.