Jump to content

I need help with this.


onox37

Recommended Posts

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();

}

}

Link to comment
https://forums.phpfreaks.com/topic/85758-i-need-help-with-this/
Share on other sites

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. :D

 

Good Luck With Your Challenge! ;D

Link to comment
https://forums.phpfreaks.com/topic/85758-i-need-help-with-this/#findComment-437716
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.