Jump to content

onox37

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

onox37's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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(); } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.